views:

130

answers:

1

Hi. 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"=>"null", "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.

A: 

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
Reuben Mallaby