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

Fix GH #4344. Callback defined in a module is not triggered when the module extends an object under Rails 3.2rc2 #4596

Merged
merged 1 commit into from Jan 24, 2012

Conversation

kennyj
Copy link
Contributor

@kennyj kennyj commented Jan 22, 2012

It seems that this issue is introduced 66a587c.
Callbacks is compiled at different timing and context.

In 3.2.0.rc1
callbacks often is compiled in __define_runner method.

In 3.2.0.rc2
callbacks always is compiled in __run_callback method.

Please see also #4344

/cc @bogdan

@josevalim
Copy link
Contributor

Ping @bogdan, are you ok with this?

@kennyj does this issue exist on Rails master?

@kennyj
Copy link
Contributor Author

kennyj commented Jan 24, 2012

@josevalim There are this issue on Rails master and 3-2-stable

@@ -359,7 +359,7 @@ module ClassMethods
def __run_callbacks(key, kind, object, &blk) #:nodoc:
name = __callback_runner_name(key, kind)
unless object.respond_to?(name)
str = send("_#{kind}_callbacks").compile(key, object)
str = object.class_eval { send("_#{kind}_callbacks").compile(key, object) }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure that:

object.send("_#{kind}_callbacks").compile(key, object)

Not gonna work here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome!
It's work fine. It seems that it was mistaken how to fix.
We just call the method that belongs to object's eigen class

I'll squash and push.

@bogdan
Copy link
Contributor

bogdan commented Jan 24, 2012

Looks good, thanks @kennyj

@kennyj
Copy link
Contributor Author

kennyj commented Jan 24, 2012

@josevalim Please confirm this PR. If we should merge this to 3-2-stable, I could send PR again.

josevalim added a commit that referenced this pull request Jan 24, 2012
Fix GH #4344. Callback defined in a module is not triggered when the module extends an object under Rails 3.2rc2
@josevalim josevalim merged commit e23dbec into rails:master Jan 24, 2012
@josevalim
Copy link
Contributor

Actually, don't worry. I will backport this to 3-2-stable myself.

@josevalim
Copy link
Contributor

Please sanity check: dc826f9

@kennyj
Copy link
Contributor Author

kennyj commented Jan 24, 2012

No problem.

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

Successfully merging this pull request may close these issues.

None yet

3 participants