Value for Select

Hi

how can i define a preselct value for the Select Tag?

<%= select(:bla, :bla_id, @blaa.collect {|c| [c.name, c.id]}, {
:selected => ‘2’ } ) %>

Where is the mistake?

greetings, chaos

On 13 Jul 2008, at 19:40, Andi G. wrote:

Hi

how can i define a preselct value for the Select Tag?

<%= select(:bla, :bla_id, @blaa.collect {|c| [c.name, c.id]}, {
:selected => ‘2’ } ) %>

Where is the mistake?

:selected => 2

Fred

Andi G. wrote:

Hi

how can i define a preselct value for the Select Tag?

<%= select(:bla, :bla_id, @blaa.collect {|c| [c.name, c.id]}, {
:selected => ‘2’ } ) %>

Where is the mistake?

greetings, chaos

have you tried putting the :selected value as an integer?
I imagine it needs to match the exact value of c.id to work.

<%= select(:bla, :bla_id, @blaa.collect {|c| [c.name, c.id]},
{:selected => 2 } ) %>

Frederick C. wrote:

On 13 Jul 2008, at 19:40, Andi G. wrote:

Hi

how can i define a preselct value for the Select Tag?

<%= select(:bla, :bla_id, @blaa.collect {|c| [c.name, c.id]}, {
:selected => ‘2’ } ) %>

Where is the mistake?

:selected => 2

Fred

Yeah! This was my first post and i got so many responses, i am enthused!

I could swear i tried this, but integer was the right point! :slight_smile:

Thanks a lot, cu next time! :slight_smile:

greetings chaos

Frederick C. wrote:

:selected => 2

Fred

Dang…
should have answered quicker.