Question

I am creating a Redmine plug in for message system. For that I have created a model with name "communication.rb". here I want to create the Activerecord relationship between Communication model and User model(here User model already existing).

in user.rb

has_many :communications

in communication.rb

belongs_to :user

How could I create relationship with existing model while creating plug in

Was it helpful?

Solution

Try add somewhere in you plugin:

User.class_eval do
  has_many :communications
end
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top