I am developing an application in rails in which I have two models: user and activity. user implements devise.
The situation is that a user can own several activities, can also be part of other activities created by other users, and can also see all the activities that have been created by all users.
My problem is that I want to be able to make an index method for each of these relationships, that is, to be able to apply resources for each type of relationship, but I don’t know how to do it. I had thought about things like namespace, module or scope, but these don’t really solve my problem, which is that I can only have one index method in my user controller.
Also, I have also been implementing “raw” routes but it has given me problems, such as when doing
get “myactivities”, to: “activities#my_index”
get “myactivities/:id”, to: “activities#my_show”
The path helpers are not generated in a good way, changing the in the url / to .
Santiago Cortés is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.