in Education by
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. JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
Route concerns are needed only when you want to DRY your routes. So far you have only one route duplication (eoi) so... using a concern is an overkill here. What you actually want to do is to have 2 eoi controllers, one will be responsible for providing all eois, second only for that ones which are inside the project. For better readability I'd namespace them – put one eois_controller.rb inside projects folder and named it as Projects::EoisController, second one - as a top-level controller, named EoisController. Routes would look like this: resources :eois # will map to EoisController resources :projects do scope module: :projects do resouces :eois # will map to Projects::EoisController end end And, of course, you might want to DRY these 2 controllers afterwards.

Related questions

0 votes
    I'm trying to setup some friendly URLs on a SharePoint website. I know that I can do the ASP.Net ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 12, 2022 in Education by JackTerrance
0 votes
    The pager concerns with the ____________ a) individual page of a process b) entire process c) entire thread d) first page of a process...
asked Oct 27, 2022 in Education by JackTerrance
0 votes
    State the appropriate concept for the given statement: Petition regarding important public concerns. Please answer the above question....
asked Aug 4, 2022 in Education by JackTerrance
0 votes
    State the appropriate concept for the given statement. Efforts of companies to integrate social and environmental concerns. Please answer the above question....
asked Aug 4, 2022 in Education by JackTerrance
+1 vote
    What is true about cross-cutting concerns in Spring? A - The functions that span multiple points of an application are ... examples of cross cutting concerns. D - All of the above...
asked Oct 14, 2020 in Technology by JackTerrance
0 votes
    I have a rails application which is api only i am using gem rails-api. Now I am trying to create ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 26, 2022 in Education by JackTerrance
0 votes
    Having a nightmare with this one and think i'm going to go crazy. It must be something simple. I ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 23, 2022 in Education by JackTerrance
0 votes
    I have a field call query_data defined as text in my MySQL database. In my model I defined this ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 21, 2022 in Education by JackTerrance
0 votes
    I'm using the following in the web page but can't get a response from the server while it's ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 19, 2022 in Education by JackTerrance
0 votes
    I'm using the following in the web page but can't get a response from the server while it's ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 17, 2022 in Education by JackTerrance
0 votes
    I would like to change the user sign-in behaviour of devise in a way to redirect a user to a ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 13, 2022 in Education by JackTerrance
0 votes
    An application gateway is a _______ routing technique. A. Six-layer B. Five-layer C. Four-layer D. Seven-layer...
asked Nov 21, 2022 in Education by JackTerrance
0 votes
    We have a vmware instance hosted in our DataCentre, from which we have a AWS Direct Connect into a ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 8, 2022 in Education by JackTerrance
0 votes
    I have a data pipeline set up in Azure where I send messages to an IoTHub which then routes those ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 17, 2022 in Education by JackTerrance
0 votes
    I'm look for a GIS/Mapping tool that will give me easy SERVER-SIDE access to route information ( ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 17, 2022 in Education by JackTerrance
...