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

Instantiate observers via Railtie, and run load hooks #109

Merged
merged 1 commit into from
Jan 29, 2014
Merged

Instantiate observers via Railtie, and run load hooks #109

merged 1 commit into from
Jan 29, 2014

Conversation

ches
Copy link
Contributor

@ches ches commented Oct 29, 2013

I spent some time figuring out how to cleanly use the ActiveResource observer support in a Rails app, finding surprisingly little documentation beyond ActiveModel::Observer itself, eventually arriving at the need for this essential boilerplate in an initializer:

ActiveResource::Base.observers = # ...
ActiveResource::Base.instantiate_observers

This change packages it up as neatly as ActiveRecord observers in Rails:

# In config/application.rb
config.active_resource.observers = [:post_observer, :comment_observer]

The Railtie instantiates observers automatically, and reloads them for each request in development just like rails-observers does for ActiveRecord.

I spent some time figuring out how to cleanly use the
ActiveResource observer support in a Rails app, finding surprisingly
little documentation beyond ActiveModel::Observer itself, arriving at
the need for this essential boilerplate in an initializer:

    ActiveResource::Base.observers = # ...
    ActiveResource::Base.instantiate_observers

This change packages it up as neatly as ActiveRecord observers in Rails:

    # In config/application.rb
    config.active_resource.observers = [:post_observer, :comment_observer]

The Railtie will instantiate observers automatically, and reload them
for each request in development just like rails-observers does for
ActiveRecord.
@ches
Copy link
Contributor Author

ches commented Nov 12, 2013

Is there a mailing list where maintenance of ActiveResource is discussed? Is there anyone with release management privileges on the project who remotely cares about reviewing pull requests?

guilleiguaran added a commit that referenced this pull request Jan 29, 2014
…and-load-hooks

Instantiate observers via Railtie, and run load hooks
@guilleiguaran guilleiguaran merged commit c4eb476 into rails:master Jan 29, 2014
@ches
Copy link
Contributor Author

ches commented Jan 30, 2014

Thanks for merging @guilleiguaran! Sorry to gripe about the project activity, I just think it would be a "help me help you" to give the user base some news about the level of commitment maintainers are able to give at this point in time, and a venue for coordination if there are some others willing to step up to help.

guilleiguaran added a commit that referenced this pull request Nov 30, 2015
…and-load-hooks

Instantiate observers via Railtie, and run load hooks
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.

2 participants