Search code examples
ruby-on-railsrails-activerecordredmine-plugins

May I include in ActiveRecord model a new relation from my plugin?


I'm creating a plugin for Redmine. I want to use the core Issue model, but I want to include in it a relation with my model, which created in the plugin structure. How can I patch the Issue model for including a new relationship in my plugin?


Solution

  • You can create a decorator in your main project to decorate the Issue model:

    # app/decorators/issue_decorator.rb
    Redmine::Issue.class_eval do
      has_many :blurps # or whatever your model is called
    end