Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Extend Rails Engine’s business logic (models, controllers, helpers, etc.) easily from your application or other engine.
Ruby JavaScript
Branch: master

Merge pull request #4 from bf4/add-license-to-gemspec

[#3] Add license to gemspec, is MIT
latest commit 0a7328276c
@atd authored
Failed to load latest commit information.
lib Bump
test test/dummy/db/.gitkeep
.gitignore Gem scaffold
.travis.yml Travis support
Gemfile Gem scaffold
MIT-LICENSE Gem scaffold
README.rdoc Add to authors
Rakefile Gem scaffold
rails_engine_decorators.gemspec [#3] Add license to gemspec, is MIT

README.rdoc

Rails Engine Decorators

Extend Rails Engine's business logic (models, controllers, helpers, etc.) easily from your application or other engine.

This solution was first implemented in the Forem engine, see github.com/radar/forem/pull/260

Authors

Usage

(From Forem's patch):

Standard practice for including such changes in your application or extension is to create a file within the relevant app/models or app/controllers directory with the original class name with _decorator appended.

### Adding a custom method to the Post model:

# app/decorators/models/forem/post_decorator.rb

Forem::Post.class_eval do
  def some_method
    ...
  end
end

### Adding a custom method to the PostsController:

# app/decorators/controllers/forem/posts_controller_decorator.rb

Forem::PostsController.class_eval do
  def some_action
    ...
  end
end

The exact same format can be used to redefine an existing method.

Something went wrong with that request. Please try again.