Rails 2.3.5
I have a form where there is a form field called ‘MAX’ and I’m including a ‘MIN’ parameter as a hidden field. The MIN parameter is correctly included in the “threshold_control” param set. But, for some reason Rails isn’t including MIN in the update statement. I don’t see why at all, the MIN param is good and there in the form param set.
I guess I could do the update SQL manually. Does anyone see why the MIN param is not being included in the update statement? Thanks!
<% form_for(@threshold_control) do |f| %>
<%= f.error_messages %>
<%= hidden_field_tag(:min_max, 'same') %>
<%= f.hidden_field :min, :value => @threshold_control.min %>
@threshold_control.update_attributes(params[:threshold_control])
Processing ThresholdControlsController#update (for 127.0.0.1 at 2011-12-21 11:59:50) [PUT]
Parameters: {"commit"=>" Update ", "authenticity_token"=>"SZCCvAKRbHXEOhYp/+JcTJnMaI3YbxAP8LzwiqqfKbE=", "id"=>"71", "min_max"=>"same", "threshold_control"=>{"max"=>"12.1", "min"=>"12.0"}}
ThresholdControl Columns (87.0ms) SHOW FIELDS FROM `threshold_controls`
ThresholdControl Load (1.0ms) SELECT * FROM `threshold_controls` WHERE (`threshold_controls`.`id` = 71)
SQL (1.0ms) BEGIN
ThresholdControl Update (16.0ms) UPDATE `threshold_controls` SET `max` = 12.1, `updated_at` = '2011-12-21 11:59:51' WHERE `id` = 71
SQL (21.0ms) COMMIT
So it is included in the params:
is min an actual column in the db? Have you run all the migrations? Do you have attr_protected (or attr_accessible) on any columns on this model?
Also, as an aside, if min is a db column – you won’t need
:value=> @threshold_control.minyou should be able to just get away with:(even if you only set min on @threshold_value in the ruby action and it’s not saved)
If the above is not populating with the value of min… that would be useful to know too.