I have a Box which has many Items which belongs to a Category.
When the Box is created it has the user_id.
Items has a category_id.
I’ve seen that if you have a user_id in the table concerned it works okay:
<%= f.collection_select :category_id, Category.where(:user_id => current_user.id), :id , :name %>
But how can I get a Category collection_select from what the current_user has entered – do I have to add a user_id to Categories or can I join my tables somehow?
Maybe this way is easier:
PS: Even better if you put this in your controller, so, in case you have to change the select and add some clauses, you will not need to change almost all your views, just the controller (MVC).