Disabling model's after_find only when called from certain controllers

Posted by Lynn C on Stack Overflow See other posts from Stack Overflow or by Lynn C
Published on 2010-03-23T21:11:08Z Indexed on 2010/03/23 21:13 UTC
Read the original article Hit count: 382

I have an after_find callback in a model, but I need to disable it in a particular controller action e.g.

def index
  @people = People.find(:all) # do something here to disable after_find()?
end

def show
  @people = People.find(:all) # after_find() should still be called here!
end

What is the best way to do it?

  1. Can I pass something in to .find to disable all/particular callbacks?
  2. Can I somehow get the controller name in the model and not execute the callback based on the controller name (I don't like this)..?

Help!

© Stack Overflow or respective owner

Related posts about ruby-on-rails

Related posts about activerecord