Not able to understand how select_tag working in rails 4? -
i have following code in rails,
<%= select_tag 'profile', (options_from_collection_for_select(@profiles, :id, :name, @dealer.profileid.to_i))%>
and generating following html,
<select id="profile" name="profile"> <option value="cm profile">cm profile</option> <option value="admin profile">admin profile</option> </select>
but want value in option tag should "id" of profiles object. assigining name of @profile object
.
and schema of profile table is,
id ==> int(11) ==> auto_increment name ==> varchar(20) ==> primary key type ==> int(11)
how can ??
according syntax
<%= select_tag 'profile', (options_from_collection_for_select(@profiles, :id, :name, @dealer.profileid.to_i))%>
is right, should work intend to.
unless syntax this
options_from_collection_for_select(@profiles, :name, :name, @dealer.profileid.to_i)
will produce
<select id="profile" name="profile"> <option value="cm profile">cm profile</option> <option value="admin profile">admin profile</option> </select>
Comments
Post a Comment