Project

General

Profile

Add an attribute to a model in a plugin

Added by dinh hien over 9 years ago

How can I add an attribute to a model of a plugin?


Replies (1)

RE: Add an attribute to a model in a plugin - Added by Kirill Bezrukov (RedmineUP) over 9 years ago

Do you mean Redmine model or plugin model. If Redmine you should make a patch

module RedmineContacts
  module Patches
    module ProjectPatch
      def self.included(base) # :nodoc:
        base.send(:include, InstanceMethods)

        base.class_eval do
          unloadable
          belongs_to :contact
        end
      end

        def contact_name
           contact.name if contact
        end

    end
  end
end

unless Project.included_modules.include?(RedmineContacts::Patches::ProjectPatch)
  Project.send(:include, RedmineContacts::Patches::ProjectPatch)
end

And then

    (1-1/1)