Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scoping affects callbacks unfavorably #1350

Closed
cheerfulstoic opened this issue May 27, 2011 · 2 comments
Closed

Scoping affects callbacks unfavorably #1350

cheerfulstoic opened this issue May 27, 2011 · 2 comments

Comments

@cheerfulstoic
Copy link
Contributor

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:

stefankroes/ancestry#44

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?

@pixeltrix
Copy link
Contributor

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

@cheerfulstoic
Copy link
Contributor Author

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 pushed a commit to jake3030/rails that referenced this issue Jun 28, 2011
Signed-off-by: David Heinemeier Hansson <david@loudthinking.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants