I’ve got two tables:
Topics
-name
and
Queries
-topic_id
A query can have a topic and so I’m trying to create a select_box in my queries_form which inserts a selected topic into my topic_id attribute of my queries table.
What I already made is a functional select_box, but I’m unable to insert the selected item into the topic_id attribute…
<% form_for @query do |f| %>
....
<%= f.select :topic_id, :value => 'queries', Topic::find(:all).collect( &:name ) %>
<% f.submit "save" %>
<% end %>
Thanks a lot for helping me
First set your relationships in your model like this :
and
Then you can write in your form view this: