I have a very simple rails app to ask questions. Three Models Question, User, Teacher. Questions belong_to User and Teacher. User and Teacher has_many Questions.
I am trying to have a drop down of users and teachers to select in the Questions _form.html.erb file.
I have this collection_select and it displays fine but it will not save user id in the Questions user_id field.
<%= collection_select(:question, :user_id, User.all, :id, :name, {:prompt=>true}) %>
1. 2. 3. 4. 5. 6.
- The model
- input
- collect of users
- what will be saved
- what is displayed
- prompt with "please select"
Please tell me what I am doing wrong to save the user.id to the question.user_id