I am creating a customer database. The navigation menu will have sections for supported customers, trial customers, unsupported customers, etc. The nav menu will appear on every page. I need to get the list of customers (i.e., supported customers), but since I''m not using the company controller, I don''t have access to the methods that return the Company model data. How can I get the Application controller to access the Company model? Thanks, Richard -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Tim Shaffer
2010-Mar-10 20:31 UTC
Re: How to access multiple models in a single controller
You should be able to access your Company model from any controller. On Mar 10, 2:33 pm, richardsugg <richards...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I am creating a customer database. The navigation menu will have > sections for supported customers, trial customers, unsupported > customers, etc. The nav menu will appear on every page. > > I need to get the list of customers (i.e., supported customers), but > since I''m not using the company controller, I don''t have access to the > methods that return the Company model data. How can I get the > Application controller to access the Company model? > > Thanks, > Richard-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
richardsugg
2010-Mar-15 17:53 UTC
Re: How to access multiple models in a single controller
So in my CompanyController, I have functions index, new, edit, create, show, etc... My understanding is that one of these gets called depending on the page. If I''m creating a new company, then the new/ create is called, etc. How do I create a function that is called everytime, regardless of the context? On Mar 10, 4:31 pm, Tim Shaffer <timster...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> You should be able to access your Company model from any controller. > > On Mar 10, 2:33 pm,richardsugg<richards...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > I am creating a customer database. The navigation menu will have > > sections for supported customers, trial customers, unsupported > > customers, etc. The nav menu will appear on every page. > > > I need to get the list of customers (i.e., supported customers), but > > since I''m not using the company controller, I don''t have access to the > > methods that return the Company model data. How can I get the > > Application controller to access the Company model? > > > Thanks, > > Richard-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Frederick Cheung
2010-Mar-15 17:57 UTC
Re: How to access multiple models in a single controller
On Mar 15, 5:53 pm, richardsugg <richards...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> So in my CompanyController, I have functions index, new, edit, create, > show, etc... My understanding is that one of these gets called > depending on the page. If I''m creating a new company, then the new/ > create is called, etc. How do I create a function that is called > everytime, regardless of the context? >Sounds like you are looking for a before_filter Fred -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.