ruby-on-railsrubyredmineredmine-plugins

How to get all Users using a Plugin in Redmine/Ruby on Rails?


I'm coding a Plugin for Redmine in Ruby on Rails atm. I need to get all "Users" to link them to a "Skill". So I need all users to make a relationship to my skills. As it is a plugin, I don't want to write in the main users model in Redmine. So, I kinda want to extend or something the original user model. Anyone has a clue how I can solve this?


Solution

  • If you want to add logic to an already existing class (like adding new methods, relationships, validations, etc..), you can do it with Ruby Module#class_eval:

    User.class_eval do
      # Inside this block we add the new logic that we want to add to the User class
    
      def new_method
      end
    end