Forum: Ruby on Rails Determining which controller to write the code into!

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
18bcc556d7688096bd4daa5d72bd6c32?d=identicon&s=25 Chirantan (Guest)
on 2008-10-10 11:35
(Received via mailing list)
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
49de4cd2f26705785cbef2b15a9df7aa?d=identicon&s=25 Nick (Guest)
on 2008-10-10 15:31
(Received via mailing list)
On Oct 10, 5:34 am, Chirantan <chirantan.rajh...@gmail.com> 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
18bcc556d7688096bd4daa5d72bd6c32?d=identicon&s=25 Chirantan (Guest)
on 2008-10-13 06:19
(Received via mailing list)
Thanks Nick. It helped. I went with the same approach. Thank you for
your clarification.

Chirantan
This topic is locked and can not be replied to.