Scoping affects callbacks unfavorably #1350

cheerfulstoic opened this Issue May 27, 2011 · 2 comments


None yet

2 participants


I've been using the ancestry gem but I ran into an issue a little while ago. I created a ticket over there but haven't been able to think of a particularly good solution yet:


The ticket has all the info, but the basic idea is that in callbacks (and apparently validations) you get a scope applied to you.

I can imagine one might want the scope applied to callbacks/validations, but can't immediately think of a case.

I've been poking through the ActiveRecord source to see if there's way to undo a part of the scope or somehow mark a part of the scope to be undone in certain situations. I don't know how much I like that idea, but just unscoping everything isn't desirable either. Thoughts?


I think you're looking for only and except. You also have unscoped if you want to remove everything.

@pixeltrix pixeltrix closed this May 27, 2011

Thanks ;) I saw only and except but I wasn't sure that they were the solution to the problem. I've gone with except for the time being since I can't think of a good example where it wouldn't work.

@jake3030 jake3030 pushed a commit to jake3030/rails that referenced this issue Jun 28, 2011
@adkron adkron Fix typo in pool_conections_test [#1350 state:committed]
Signed-off-by: David Heinemeier Hansson <>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment