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
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.