# select\_tag not posting selection

**URL:** <https://discuss.rubyonrails.org/t/select-tag-not-posting-selection/55747>\
**Category:** rubyonrails-talk\
**Created:** [November 16, 2010, 10:22pm UTC](https://discuss.rubyonrails.org/t/select-tag-not-posting-selection/55747 "2010-11-16T22:22:06Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![11155](https://avatars.discourse-cdn.com/v4/letter/1/d26b3c/32.png) [@11155](https://discuss.rubyonrails.org/u/11155)\
**Post date:** [November 16, 2010, 10:22pm UTC](https://discuss.rubyonrails.org/t/select-tag-not-posting-selection/55747/1 "2010-11-16T22:22:06Z")

</div>

Here is the (Partial) code in the \_form.html.erb: ---code fragment--- \<%= form\_for(@order) do |f| %\> &nbsp;&nbsp;\<% if @order.errors.any? %\> &nbsp;&nbsp;&nbsp;&nbsp;\<div id="error\_explanation"\> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\<h2\>\<%= pluralize(@order.errors.count, "error") %\> prohibited this order from being saved:\</h2\>

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\<ul\> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\<% @order.errors.full\_messages.each do |msg| %\> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\<li\>\<%= msg %\>\</li\> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\<% end %\> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\</ul\> &nbsp;&nbsp;&nbsp;&nbsp;\</div\> &nbsp;&nbsp;\<% end %\>

&nbsp;&nbsp;\<div class="field"\>

&nbsp;&nbsp;&nbsp;&nbsp;\<%= select\_tag(:Client, options\_from\_collection\_for\_select(Client.all, :id, :Company\_Name))%\> &nbsp;&nbsp;\</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.

---

<div class="post-metadata">

**Author:** ![11155](https://avatars.discourse-cdn.com/v4/letter/1/d26b3c/32.png) [@11155](https://discuss.rubyonrails.org/u/11155)\
**Post date:** [November 17, 2010, 8:51pm UTC](https://discuss.rubyonrails.org/t/select-tag-not-posting-selection/55747/2 "2010-11-17T20:51:59Z")

</div>

Erick C. wrote in post #961955:

> Here is the (Partial) code in the \_form.html.erb: ---code fragment--- \<%= form\_for(@order) do |f| %\> &nbsp;&nbsp;\<% if @order.errors.any? %\> &nbsp;&nbsp;&nbsp;&nbsp;\<div id="error\_explanation"\> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\<h2\>\<%= pluralize(@order.errors.count, "error") %\> prohibited this order from being saved:\</h2\>
> 
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\<ul\> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\<% @order.errors.full\_messages.each do |msg| %\> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\<li\>\<%= msg %\>\</li\> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\<% end %\> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\</ul\> &nbsp;&nbsp;&nbsp;&nbsp;\</div\> &nbsp;&nbsp;\<% end %\>
> 
> &nbsp;&nbsp;\<div class="field"\>
> 
> &nbsp;&nbsp;&nbsp;&nbsp;\<%= select\_tag(:Client, options\_from\_collection\_for\_select(Client.all, :id, :Company\_Name))%\> &nbsp;&nbsp;\</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.

Best,

---

<div class="post-metadata">

**Author:** ![Colin\_Law1](https://avatars.discourse-cdn.com/v4/letter/c/91b2a8/32.png) [@Colin\_Law1](https://discuss.rubyonrails.org/u/Colin_Law1)\
**Post date:** [November 17, 2010, 9:20pm UTC](https://discuss.rubyonrails.org/t/select-tag-not-posting-selection/55747/3 "2010-11-17T21:20:24Z")

</div>

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
