开发者

update action not saving data

I am having trouble getting a form text area to update a field in a rails 3.0.8 app. I keep stripping out as much as i can to narrow down where the error lies. Here's what is left.

My form:

<%= form_for @fb_comments, :remote => true, :html => { :'data-type' => 'html', :id => 开发者_如何转开发'comment' } do |form| %>
    <%= form.text_area :comment %>
    <%= form.submit "Update Comments" %>
<% end %>

The dummy data that i put into the comment column via mysql for this record shows up so the current data is making it to the form.

controller:

def update
   fbc = FbComments.find(params[:id])
   fbc.update_attributes(params[:comment])
   ...
end

console message:

Started POST "/fb_comments/1" for 127.0.0.1 at 2011-06-13 17:31:43 -0400
  Processing by FbCommentsController#update as HTML
  Parameters: {"utf8"=>"✓", "authenticity_token"=>"gLA2A11uVRl/WtIR1p90aSkLoU6b8twotK+B1YNefRk=", "fb_comments"=>{"comment"=>"test test"}, "commit"=>"Update Comments", "id"=>"1"}
  FbComments Load (0.1ms)  SELECT `fb_comments`.* FROM `fb_comments` WHERE `fb_comments`.`id` = 1 LIMIT 1
  SQL (0.1ms)  BEGIN
  SQL (0.1ms)  COMMIT
Rendered text template (0.0ms)
Completed 200 OK in 15ms (Views: 0.6ms | ActiveRecord: 0.3ms)

Thanks.


Your controller is recieving fb_comments not comment:

fbc.update_attributes(params[:fb_comments])

Hoe this helps.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜