Collection_Select not showing Selected option

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;

Product Line <%= @drivers.product_line.name %> # Troubleshooting only <%= collection_select(:driver,"product_line_id",@productline,:id,:name) %> ###

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: {}

On 12 Jan 2008, at 19:53, deadSkip wrote:

Here’s the code;

Product Line <%= @drivers.product_line.name %> # Troubleshooting only <%= collection_select(:driver,"product_line_id",@productline,:id,:name) %>

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

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs