I am trying to figure out how to use concerns in my routes file.
I have models called User, Project and Eoi.
The associations are:
User
has_many :eois
Project
has_many :eois
Eoi
belongs_to :user
belongs_to :project
I am trying to make a system to show eois that have been submitted on a project, so that they are visible only to the user that made the project.
Separately, I want to show every user all of the eois that user made (regardless of which project they are made on).
I think I want nested routes for the first scenario and then I also want eoi routes that are not nested for the second scenario.
In my routes.rb
I have:
resources :projects do
# concerns: :eois,
member do
resources :eois
end
I also want to have:
resources :eois
How can I make this work? I can't get the hang of the examples in this http://api.rubyonrails.org/classes/ActionDispatch/Routing/Mapper/Concerns.html
I don't understand whether commendable in the example is a model or if its something I need to write to be able to have routes in two places in the routes.rb file.
My next attempt is to try to copy the gist of the example in the above link, I have
resources :eois#, only: [:index]
concern :eoiable do
resources :eois
end
resources :projects do
concerns :eoiable
end
I'm not sure if i need to make a definition somewhere to get this working.