Reputation: 468
I'm creating plugin for redmine. I need to add action in projects controller. I made a patch for ProjectsControllers
module ProjectsControllerPatch
def self.included(base) # :nodoc:
base.extend(ClassMethods)
base.send(:include, InstanceMethods)
end
module ClassMethods
end
module InstanceMethod
def new_method
end
end
end
# Add module to Issue
ProjectsController.send(:include, ProjectsControllerPatch)
And added route in routes.rb:
get 'new_method', :to => 'projets#new_method'
But I have 404 error on this route
Upvotes: 1
Views: 722
Reputation: 770
You need to define route like this:
RedmineApp::Application.routes.draw do
match 'issue/:issue_id/something/:action/:id', to: 'something#new_some', as: 'fancy_route'
end
After that register this route in your plugin:
project_module :my_plugin do
permission :my_plugin, { :my_plugin => [:fancy_route] },:public => true
end
Live example from iCalendar plugin:
project_module :redmine_icalendar do
permission :redmine_icalendar, {:redmine_icalendar => [:index, :show, :list]}, :public => true
permission :redmine_icalendar, {:redmine_icalendar => [:edit, :new, :destroy]}, :require => :member
end
Upvotes: 1