Forum: Ruby on Rails Populating Select Dropdown for Editing?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
0ccc3bfe33945df7b1a68f17385ce722?d=identicon&s=25 Nick Faraday (Guest)
on 2009-05-19 02:02
(Received via mailing list)
I'm having trouble populating a select tag in a form?

I have moved the form to a partial so it can be used in both the
create and edit views.  My standard text fields are populated with
data from the DB just fine in the edit view, but I can't seem to get
the select drop downs to work?

How do I force the default value of a select to the value stored in
the DB?  Below is an example of what I have:

<label for="hours_sunday_open">Open:</label><%= f.select
(:hours_sunday_open, @site.open_close_times) %>

I've tried the :selected => f.hours_sunday_open

It didn't seem to work.

Thanks
This topic is locked and can not be replied to.