Model Knowledge Of Controller Calling It

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’.

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

Howdy -

On 2-Mar-09, at 2:21 PM, Starr H. 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

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!