Here are my tables (short version)
People
id
fname
lname
state_id
States
id
name
I have the _form.rhtml working in a basic sense:
<label for="person_state_id">State</label>: <%= select("person",
"state_id", State.find(:all).collect {|s| [s.name, s.id]} ) %>
It works fine when I am creating a new record. I select the state I
want and the ID goes into the state_id field. The problem is when I
go to edit the page it defaults to "Alabama," the first record. I
need it to select the correct state ID. I have played with it a lot
and basically I need it to print this: selected="selected" on the
correct state.
even after trying above code, are you facing same problem?
why because, according to rails document if you pass :selected options
surely it should work.
You are missing a ')' somewhere above the line with the 'end' (i.e., line 94) and the interpreter knows that 'end' isn't valid at that point so that's where it complains.