Forum: Ruby on Rails Populating Select Dropdown for Editing?

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Nick Faraday (Guest)
on 2009-05-19 04: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><%=
(:hours_sunday_open, @site.open_close_times) %>

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

It didn't seem to work.

This topic is locked and can not be replied to.