Foreign key output to Rails overpass 3 views

I created 2 models using scaffolding with Rails 3. Models are places and tasks, and each task has a location.

I created the required reference calls in the scaffold generation code, but when I look at the view to create a new task, all I see is a text box where I have to add location_id.

How can I make this be a drop down list instead of a better user experience?

+5
source share
1 answer

Imagine what you have titlefor each location

<%= f.collection_select :location_id, Location.all, :id, :title %>

API: http://apidock.com/rails/ActionView/Helpers/FormOptionsHelper/collection_select

+15

All Articles