I have a simple model called Discussion which has a boolean column called resolved.
In my form, I have the following code
<%= form_for(@discussion) do |d| %>
...
<%= d.check_box :resolved %>
<% end %>
And in my controller, I have the following:
def update
@discussion = Discussion.find(params[:id])
if @discussion.update_attributes(params[:discussion])
etc...
end
end
When I submit the form, I can see that the parameters are being sent to the server...
Parameters: {"utf8"=>"✓", "authenticity_token"=>"AsGsRHwiVva/+kTrBs0IjLeZwj1ZmXBuKZr9Pg/N6Xk=", "discussion"=>{"shortdesc"=>"Talk about something.", "content"=>"Try to update check box.", "resolved"=>"1"}, "commit"=>"Update Discussion", "id"=>"1"}
But the query doesn't include anything about updating that field.
AREL (14.9ms) UPDATE "discussions" SET "content" = 'Try to update check box.', "updated_at" = '2011-07-18 17:53:50.783176' WHERE "discussions"."id" = 1
Any idea on what I'm missing?
There are 4 reasons why this could be happening:
resolved
is already set to true in the database.resolved=
method in your model and it no longer sets the attribute.attr_protected :resolved
.attr_accessible
but do not have :resolved
in the list.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With