Say I got some lists and some tasks. Each list can have many tasks, a task belongs to a list. When I editing one of the tasks rails is showing the id of the corresponding list in the inputfield.
How is it possible to show the title of the list instead of the id?
You probably want to use a select
input, something similar to this in your form code:
<%= f.select :list_id, List.all.collect { |l| [l.name, l.id] } %>
This will display the name
of each List
, but will actually assign the id
to the task's list_id