English 中文(简体)
Railways form =>URL => JSON = 。 Save params
原标题:Rails form => URL => JSON => Save params
问题回答

for rest api you can use activeresource in your application http://api.rubyonrails.org/classes/ActiveResource/Base.html

如果它具有非常具体的内容,你可以使用网: Http. 提出请求,然后由 yourself将json to带给废墟。

http://www.rubyinside.com/net

for decoding json you can use Json or ActiveSupport::JSON.decode or this https://github.com/flori/json

我猜想你想向不是你的所在地的其他人提出答复。 因此,你可以安装 curb灯(在废墟中安装 cur窗)。 然后,它利用Json至Ah等固定的RoR工具,在另一个地点和分区提出要求。

http://www.rubyinside.com/net 你可以做以下工作:

在您的档案中添加:

require "net/http"
require "uri"
require  json 

当时担任你的控制员或助手:

#set the uri
uri = URI.parse("http://my.site.com/uri")

#set the post params and get the respons
response = Net::HTTP.post_form(uri, {"first_param" => "my param", "second_param" => "another param"})

#get the json info
data = JSON.parse(response.body)

#set result to an ActiveRecord (maybe there is a better way to do this, I guess it depends on the response you get
@something = Mymodel.new
@something.name = data["name"]
...
@something.save

希望!





相关问题
ajax login using httpRequest?

I am trying to develop my login script to give feedback to the user if the login is valid or not. Basically if it isn t correct a div box will show saying its wrong, if its correct it will show its ...

Virtual Tour using sketch up, ajax, flash technologies

I want to know if there are existing technology that make your 3d models in sketch into virtual tours, using either Ajax or Flash for web presentation. If there s none, which will be a good approach ...

How can i update div continuously

I have asp.net application where i have a div which showing the value from other site. The value of that site is changing continuously. I want that my div will automatically update in some interval ...

热门标签