Project

General

Profile

Actions

Feature #2142

closed

Change the way plugin routes are integrated

Added by Jean-Baptiste Barth about 16 years ago. Updated almost 15 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Plugin API
Target version:
Start date:
2008-11-07
Due date:
% Done:

100%

Estimated time:
Resolution:
Fixed

Description

Plugin's routes can today ( r1977 ) be handled thanks to a hook in the config/routes.rb :

Redmine::Hook.call_hook :routes, :map => map
The developper has to define his routes in vendor/plugins/redmine_myplugin/init.rb (in the register block) :
    class MyRoutes < Redmine::Hook::Listener
      def routes(context)
        context[:map].resources :mymodel
        context[:map].connect 'mypath/:blah', :controller => 'mycontroller'
        #etc.
      end
    end
    Redmine::Hook.add_listener(MyRoutes)

Maybe it is possible to use Engines system to handle each plugin's routes, with "map.from_plugin" method :
- in config/routes.rb

    Rails.plugins.each do |plugin|
      map.from_plugin plugin.name.to_sym
    end
- in vendor/plugins/redmine_myplugin/routes.rb
    resources :mymodel
    connect 'mypath/:blah', :controller => 'mycontroller'

It has been discussed here in the forum. Maybe it would be easier to use for plugin developpers, but I'm not 100% sure routes overriding will produce the same effect.

Actions

Also available in: Atom PDF