Andrew M. Campbell
2005-Mar-12 02:14 UTC
Accessing model''s not associated with the current model of a controller.
Hello, I have a strange setup where I need to access a model from within a controller and the model has no association with the controller. That probably does not make any sense. However look at this: http://andrewc.mdns.org/print.pdf I need to access GenreList from with the controllers for Movie and Music. GenreList is only used to access the appropriate list of genre''s for a given ArtForm (such as moveis and music). I''ve not been succesful in accessing GenreList. Is this possible? Given my crappy diagram, do you see a better way? I appreciate your time. Thank you, Andrew M. Campbell
Tim Lucas
2005-Mar-12 02:58 UTC
Re: Accessing model''s not associated with the current model of a controller.
On 12/03/2005, at 1:14 PM, Andrew M. Campbell wrote:> I have a strange setup where I need to access a model > from within a controller and the model has no > association with the controller.It''s not at all unusual to access other model objects from your controller. You''ll just need to add a: require_dependency ''othermodel'' - tim lucas
Andrew M. Campbell
2005-Mar-12 03:09 UTC
Re: Accessing model''s not associated with the current model of a controller.
> You''ll just need to add a: > require_dependency ''othermodel''Cool, I appreciate the response. Thank you, Andrew M. Campbell
Dylan
2005-Mar-12 07:49 UTC
Re: Accessing model''s not associated with the current model of a controller.
Tim Lucas wrote:> On 12/03/2005, at 1:14 PM, Andrew M. Campbell wrote: > >> I have a strange setup where I need to access a model >> from within a controller and the model has no >> association with the controller. > > > It''s not at all unusual to access other model objects from your controller. > > You''ll just need to add a: > require_dependency ''othermodel'' >you can also use the model dependancy which is the preferred way according to the docs, see ActionController::Dependencies::ClassMethods in the api