No commit activity in last 3 years
No release in over 3 years
Extend Rails Engine's business logic (models, controllers, helpers, etc.) easily from your application or other engine.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

>= 3.2.8
 Project Readme

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.