Rails, Rest - how to get post data from ajax calls
I am developing rest app in Rails and I have a problem. I send ajax post request to rails rest app
update_feedback : function(attrs, success, error){
$.ajax({
url: '/sync/feedback',
type: 'post',
dataType: 'json',
success: success,
error: error,
data: attrs,
fixture: false
})
}
Webrick server says
Processing Sync::FeedbackController#create (for 127.0.0.1 at 2010-01-11 15:11:33) [POST] Parameters: {"created_at"=>"2009/11/15 12:37:49 +0100", "blog_name"=>"null", "title"=>"nu开发者_如何学Goll", "guid"=>"74a27fb2-0e36-4ff0-a77e-5b9617a7549d", "body"=>"test", "author"=>"tibor"}
And now I don't know, how to get data from post request in rails app. For instance I need to get author param or create a new comment. I tried this code, but it doesn't work
def create
@comment = Feedback.new params[:post]
@comment.save
end
My Rest app is working and all get requests work pretty well. How can I get all params and every param each then. Thank you for your help.
What is your form id? If created as standard your parameters for Feedback will be named such as:
def create
@comment = Feedback.new params[:feedback]
@comment.save
end
精彩评论