googleads
How to Create a Redmine Plugin | Hire Ruby on Rails developers
preloder
Ruby on Rails Standard Technical Tips & Tricks

Redmine Plugin Development

I have written this article with the purpose of explaining how to develop a Redmine Plugin. So let us go about this basic introduction into Redmine Plugin, and how to go about developing it.

What is Redmine?

The basic definition of Redmine is this – Redmine is a project management tool which is a flexible open source software. It is cross-platform and cross-database tool, developed using the Ruby on Rails framework.

Why Redmine Plugins?

As is the case with any technology, plugins will extend the functionalities of Redmine. They will do so without modifying the Redmine core. They can also be easily added/removed into the Redmine application.

Creating a new Redmine Plugin

In order to create a new plugin, you need to use the generator mentioned below. This will generate a new plugin under the application’s plugins directory.

 

To modify the plugin information, edit the init.rb file located in plugins/plugin_name/init.rb. Next, you have to restart the application so as to see the new plugin appear in the plugins list. Now that a new plugin has been created, we need to generate a model for the same.

Generating a model

In order to create a new model, run the below generator so that it creates the model and the corresponding migration. And then, migrate the database using the following command:

 

In order to migrate the plugins migration files:

 

Obviously, next is to generate a controller.

Generating a controller

In order to create a new controller, run this generator:

 

Adding routes

Edit the file in: plugins/pluginName/config/routes.rb in order to add the routes.

Extending menus

In order to edit the menus, you need to edit the file: plugins/plugin/init.rb and add the following line at the end of the plugin registration.

 

Syntax is:

 

When do we need to extend?

Sometimes plugins require a specific feature implemented in the Redmine core or the plugin overrides a specific view.

  • Add new methods to a model/controller
  • Wrap an existing method to a model/controller
  • Changing the existing view

Extending redmine model/controller

We can not override a controller and model in redmine from Plugins. But it is easy to extend the models and controllers.

Adding a new method

Create a new module under plugins/plugin/lib directory.

 

Wrapping an existing method

Wrapping can only be done once per method. If multiple plugins are wrapping the same method, then only the last wrapping would be valid. And so, all the previous ones would be ignored.

Create new module under plugins/plugin/lib directory.

 

Changing the existing view

 

  • Unlike Model and Controller, we can override redmine views by just adding the files under plugins view directory.
  • For example, in order to override the view page, the below file can be added:

          /plugins/my_plugin/app/views/projects/view.html.erb.

Thus, a basic Redmine plugin has been developed. Try it out, and see for yourself how this can help with your development. For more on Ruby on Rails development follow Agira Technologies.

The following two tabs change content below.

Saravana

An enthusiastic Tech Lead with 7 plus years of experience in Web development arena. Owns legitimate experience in Ruby, Ruby On Rails, AngularJs, DevOps. Golang, Another add on, This young tech freak never miss a chance to get his hands on planting and Gardening even in his busy weekends.

Leave a Reply

Your email address will not be published. Required fields are marked *

[contact-form-7 id="120788" title="Web Page Form"]

Schedule Your Call