Forum: Ruby on Rails collection select bug (?)

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
2dddec0f7717cae77ac6bceede6be5bc?d=identicon&s=25 Ram (Guest)
on 2008-12-05 07:23
(Received via mailing list)
Consider this code

<%= collection_select :cheque, :salary_component, Components.find
(:all), :value, :name %>

To input the value of a salary component into a Cheque model.
salary_component is an attribute of the Cheque model.
I want the user to see the name of the component in the select
fields.. such as basic, house rent, bonus, etc
And the amounts attributed to each of these components to get into the
salary_component column of the cheques table... such as 3000, 200,
Component is a model of its own.
No association between Cheque and Component because, if one of the
Components are deleted, i do not want the cheques using those
components to get affected.
Now, this same line in the edit page, does not show the previously
selected value in the select.
ie. if when a particular cheque was created, the 'basic' component was
selected, the amount attributed to 'basic' gets into the db but when
editing this cheque, the existing value in the collection_select is
not 'basic'.
I guess its a mapping bug. Please correct me if im wrong and DO let me
know how to fix this. Pardon the imperfect example.
This topic is locked and can not be replied to.