GithubHelp home page GithubHelp logo

mariochavez / rails_engine_decorators Goto Github PK

View Code? Open in Web Editor NEW

This project forked from atd/rails_engine_decorators

0.0 2.0 0.0 90 KB

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

License: MIT License

Ruby 83.87% JavaScript 2.95% CSS 2.52% HTML 10.66%

rails_engine_decorators's Introduction

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.

rails_engine_decorators's People

Contributors

atd avatar bf4 avatar

Watchers

Mario Alberto Chávez avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.