Hello everyone, I''m trying to wire a combobox in a view to update the database. When I select something in the combobox and press ''update'' it goes through fine, except it places the default value for the field of the combobox. Any suggestions? Here''s the model: class TestResult < ActiveRecord::Base has_one :status_index has_one :test_type has_one :product_area validates_presence_of :statusindex_id, :testtype_id, :productarea_id, :name end This generates the combobox (inside a view partial): <%= select("test_type", "id", TestType.find_all.collect {|tt| [tt.name, tt.id] }, { :include_blank => false}) %> Here''s the command in the controller''s ''update'' method: @test_result.update_attributes(params[:test_result]) Thanks very much, Roy Tinker -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060719/0efc7080/attachment-0001.html
Bill Walton
2006-Jul-20 00:54 UTC
[Rails] Updating a model from a checkbox (noob question)
Updating a model from a checkbox (noob question)Hi Roy, Roy Tinker wrote:> <%= select("test_type", "id", TestType.find_all.collect > {|tt| [tt.name, tt.id] }, { :include_blank => false}) %>> Here''s the command in the controller''s ''update'' method: > @test_result.update_attributes(params[:test_result])I could be wrong, but based on what you''ve shown us, I''m pretty sure the result of your select is going to come back to the controller in params[:test_type][:id], not in params[:test_result]. But I could definitely be wrong because I don''t have any experience with using.find''s in my views. You might want to use a ''dummy'' view with <%= params.inspect %> to check to see exactly what _is_ coming back. hth, Bill