0
votes

I've added a select box to a form partial, but unsure about how to pull the currently selected value in the database back into the select box.

Here's what I have in my partial: <%= f.select 'status', options_for_select([['Publish', 1], ['Draft', 2]], 1) %>

I know that the last "1" is currently setting the value when the page is loaded. However, I'm not sure about what to place in this position to pull the selected value out of the db. How do I go about doing this in a partial that uses new and edit methods in the controller?

1

1 Answers

0
votes

This should "just work" if you have an instance variable loaded. I'm going to guess that your column is actually named status_id, in which case you should use that instead of status in your select call.

If not, please post what your model and controller actions look like.