On 12 Jan 2008, at 19:53, deadSkip wrote:
>
> Hi, I''m having some problem with getting collection_select to
return
> the current value when editing a record. According to everything
I''ve
> seen, there was an issue but it''s been fixed, but I can''t
figure out
> why it isn''t returning the current value as a selected option.
I''ve
> checked the table structures, and both the call_driver.product_line_id
> and the product_line.id are int(11).
>
> What am I missing?
>
> Here''s the code;
>
> ###
> <tr>
> <td>Product Line</td>
> <td><%= @drivers.product_line.name %></td> #
Troubleshooting only
> <td><%>
collection_select(:driver,"product_line_id",@productline,:id,:name)
> %></td>
Your instance variables is called @drivers, so the first parameter to
collection_select must match, i.e. be :drivers (although in this case
it looks like it would make more sense o rename the instance variable
to @driver
Fred>
> </tr>
> ###
>
> The controller;
>
> ###
> def driver_edit
> @drivers = CallDriver.find(params[:id])
> @productline = ProductLine.find(:all)
> end
> ###
>
> And the debug results for CallDriver
>
> --- &id001 !ruby/object:CallDriver
> attributes:
> name: Billing (TV)
> segment_id: "1"
> platform_id: "1"
> updated_at:
> product_line_id: "3"
> id: "2"
> sub_product_line_id: "7"
> consolidation_id: "1"
> skill_id: "1"
> created_at: 2008-01-10 20:04:04
> attributes_cache: {}
>
> Debug results for ProductLine;
>
> - !ruby/object:ProductLine
> attributes:
> name: RHP
> updated_at:
> id: "1"
> created_at: 2008-01-09 20:16:56
> attributes_cache: {}
>
> - !ruby/object:ProductLine
> attributes:
> name: Internet
> updated_at:
> id: "2"
> created_at: 2008-01-09 20:16:56
> attributes_cache: {}
>
> - !ruby/object:ProductLine
> attributes:
> name: TV
> updated_at:
> id: "3"
> created_at: 2008-01-09 20:16:56
> attributes_cache: {}
>
> - !ruby/object:ProductLine
> attributes:
> name: Wireless
> updated_at:
> id: "4"
> created_at: 2008-01-09 20:16:57
> attributes_cache: {}
>
> >
--~--~---------~--~----~------------~-------~--~----~
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
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---