On 17 November 2010 20:51, Marnen Laibow-Koser <[email protected]> wrote: > Erick C. wrote in post #961955: >> Here is the (Partial) code in the _form.html.erb: >> ---code fragment--- >> <%= form_for(@order) do |f| %> >> <% if @order.errors.any? %> >> <div id="error_explanation"> >> <h2><%= pluralize(@order.errors.count, "error") %> prohibited this >> order from being saved:</h2> >> >> <ul> >> <% @order.errors.full_messages.each do |msg| %> >> <li><%= msg %></li> >> <% end %> >> </ul> >> </div> >> <% end %> >> >> <div class="field"> >> >> <%= select_tag(:Client, >> options_from_collection_for_select(Client.all, :id, :Company_Name))%> >> </div> >> ---end code fragment--- >> >> This is the error: >> ---server log ---- >> Parameters: {"utf8"=>"✓", >> "authenticity_token"=>"crNdvzlzzYskmxgmITfYMLHoR49/xYFmZ8NGhK/SwOk=", >> "Client_ID"=>"2", "order"=>{"Product_ID"=>"1", "Flats"=>"100", >> "Order_date(1i)"=>"2010", "Order_date(2i)"=>"11", >> "Order_date(3i)"=>"16", "Due_date(1i)"=>"2010", "Due_date(2i)"=>"11", >> "Due_date(3i)"=>"16", "Ship_date(1i)"=>"2010", "Ship_date(2i)"=>"11", >> "Ship_date(3i)"=>"16", "Status"=>"P"}, "commit"=>"Update Order", >> "id"=>"2"} >> ----end server log--- >> >> Note that the variable "Client_ID"=>"2" is not inside the update order >> string, so, the value is not saved in the database table for record 2. > > All the capital letters seem odd, and are probably preventing Rails from > mapping things correctly. Every capital letter in that example should > be lowercase.
Except Client.all, but that should not be in the view at all, it is bad practice to call model code from the view, set up @clients_for_selection or whatever in the controller. Colin -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

