Determining which controller to write the code into!


#1

This question is more about how things work in an MVC architecture
based ORM application. I want to know which controller to write code
into when there is a many to many relationship between 2 models.

Example,

I have a model A and model B with respective controllers and have a
many to many realastionship. I want to list Bs that are associated
with A in using bridge table. Which controller should the code for
this go since both are equally related.

Chirantan


#2

On Oct 10, 5:34 am, Chirantan removed_email_address@domain.invalid wrote:

Chirantan

Hi Chirantan. Controller methods generally map to actions that are
performed on models. So a method named “new” in the User model would
allow you to create a new User. In other words, if you want to do
something to ModelA, you’d put the method in ModelA’s controller.

To answer your question, if I wanted to list all Bs associated with a
particular A, I would probably create a method in the A controller
called “list_Bs”.

Hope that helps,
Nick


#3

Thanks Nick. It helped. I went with the same approach. Thank you for
your clarification.

Chirantan