Closed SageBeard closed 5 years ago
What is the trouble you are are having, are you getting an error, or is it not returning correct data?
Your question is set up nice, but it is very open ended and doesn't provide guidance on what assistance I can provide.
I'm getting an error with how I'm setting up my form below. My question is how to correctly set-up the collection_select method. I'm confused by the examples I've seen .
<%= f.label :collaborator, class: 'checkbox' do %>
<%= f.collection_select(:user, :user_id, User.all, :id) %>
Sorry this is still a bit open ended. Steps to reproduce the error is always needed as well as the actual error message.
I did the following to get this error but not 100% sure this is what you are looking at.
I googled it and found this and realized this is the wrong approach. https://stackoverflow.com/questions/10741810/collection-select-undefined-method-map-for-nilnilclass
app/views/collaborators/_collaborator_form.html.erb should host the form app/controllers/collaborators_controller.rb should have a create, destroy, and new method. Very similar to wikis controller.
Making these changes will put in the right direction.
I've set up my three models - user, wiki & collaborator - to have a HSMT relationship. My next step is to create a drop down 'collaborator' menu on the wiki form. The menu would list out all users that the premium user can choose from to select or edit their collaborator for that wiki. I've set up my form below, but am having trouble figuring out how to properly set-up the collection_select method: '(object, method, collection, value_method, text_method, options = {}, html_options = {})'
Wiki Model
User Model
Collaborator Model
_form.html.erb