Does anyone know a good way for a Model to be aware of which Controller is calling it? For example, I have an after_find method that should always be called unless the Controller is the ''FooController''. --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
> Does anyone know a good way for a Model to be aware of which > Controller is calling it? For example, I have an after_find method > that should always be called unless the Controller is the > ''FooController''.This doesn''t sound like such a good idea. Isn''t the whole point of the MVC architecture is that the models are separate from the controller? SH --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Howdy - On 2-Mar-09, at 2:21 PM, Starr Horne wrote:> >> Does anyone know a good way for a Model to be aware of which >> Controller is calling it? For example, I have an after_find method >> that should always be called unless the Controller is the >> ''FooController''. > > This doesn''t sound like such a good idea. Isn''t the whole point of the > MVC architecture is that the models are separate from the controller?I suggest you consider what it means in the problem domain to come from that controller - ie. is that an admin controller, thus administrating is the consideration?) If so the issue is about admin access - not the controller -ie the controller is immaterial, and admin access may be achieved through a web service, not through this controller, but another way to designate admin access. I hope the above isn''t confusing - the domain is what you should be concerned about - not the implicit considerations based on the technology (controller). J --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Valid point... I forgot about the whole autonomy thing, silly me. Here is the real reason, perhaps someone has an idea... I am loading feeds. I have a after_find method called read_feed that check to see if we need to reload the feed cache and update the information. This all works great on the majority of the site. However, when working in the feeds admin area, even with paging, we are loading 30 feeds at a time for admin purposes, and if they all need to be recached, it can take a long time for the page to render. So what I want is a way to disable automatic caching for the admin area only. One idea is to invoke the initialize method in the feeds controller, and set a switch on the Model to do_not_cache, but I thought this might get a little but messy. Any other ideas or suggestions? Thanks! On Mar 2, 2:29 pm, Jodi Showers <j...-BOB1p6JRLoAV+D8aMU/kSg@public.gmane.org> wrote:> Howdy - > > On 2-Mar-09, at 2:21 PM, Starr Horne wrote: > > > > >> Does anyone know a good way for a Model to be aware of which > >> Controller is calling it? For example, I have an after_find method > >> that should always be called unless the Controller is the > >> ''FooController''. > > > This doesn''t sound like such a good idea. Isn''t the whole point of the > > MVC architecture is that the models are separate from the controller? > > I suggest you consider what it means in the problem domain to come > from that controller - ie. is that an admin controller, thus > administrating is the consideration?) > > If so the issue is about admin access - not the controller -ie the > controller is immaterial, and admin access may be achieved through a > web service, not through this controller, but another way to designate > admin access. > > I hope the above isn''t confusing - the domain is what you should be > concerned about - not the implicit considerations based on the > technology (controller). > > J--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@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 -~----------~----~----~----~------~----~------~--~---