Project

General

Profile

Redmine 2.0: 404 errors after creating plugin to add top menu links

Added by marco deluca over 12 years ago

This was working for me with redmine 1.3. After upgrade to 2.0.3, I get 404 errors when trying to add custom links to the top menu. This was what worked previously, after creating a plugin called add_link, editing the init.rb file to the following:

require 'redmine'

Redmine::Plugin.register :redmine_rt_link do
  name 'Redmine Add Link'
  author 'Holger Just'
  url 'http://dev.holgerjust.de/projects/redmine-misc'
  author_url 'http://meine-er.de'
  version '0.1.0'
  requires_redmine :version_or_higher => '0.8.0'

  # caption can also be a i18n symbol or a proc
  menu :top_menu, :my_link, {:controller => 'my_controller', :action => 'my_action'},
       :caption => "My title" 
end

I was able to create links like this:
menu :top_menu, :activity, "http://domain.com/activity"
menu :top_menu, :issues, "http://domain.com/issues"

I dont know if I was making a mistake with the syntax above, I had it working fine with 1.3.x but anyway, in case anyone else is having problems with this, that simple string of text above works fine.

This is my environment:
Redmine version 2.0.3.stable
Ruby version 1.9.3 (x86_64-linux)
Rails version 3.2.6
Environment production
Database adapter Mysql2


Replies (4)

RE: Redmine 2.0: 404 errors after creating plugin to add top menu links - Added by Jan Niggemann (redmine.org team member) over 12 years ago

What's the error message you're seeing? Is there something in the logfile?

Add "View all issues" to the top menu:
https://github.com/jniggemann/Redmine-All-Issues/blob/master/init.rb

Edit: HTTP error 404 is, of course, page not found. Are your routes OK?

RE: Redmine 2.0: 404 errors after creating plugin to add top menu links - Added by marco deluca over 12 years ago

I followed the syntax of the 'view all issues' example you provided and that worked. I was able to duplicate that for activities as well. To be honest, I can't see what the difference is between that example and the one above. The error I was getting was a 404 page for every single page EXCEPT the custom link I was trying to create. Since its working fine now, all's good.

Thanks for that example too, that was great.

RE: Redmine 2.0: 404 errors after creating plugin to add top menu links - Added by Jan Niggemann (redmine.org team member) over 12 years ago

The only difference I spot is that you don't refer to a project (:project_id => Herve Harster)...

RE: Redmine 2.0: 404 errors after creating plugin to add top menu links - Added by Derric Atzrott over 11 years ago

I also ran into this issue and for me it turned out to be a routes issue.

Redmine 2.X no longer has default routes for plugins, so you have to make sure that you add your routes to config/routes.rb else every page is going to be a 404 as soon as you try to add a link to one of your plugin's pages.

In my case my menu line was as such:

menu :top_menu, :pm_alert, { :controller => 'report', :action => 'index', :project_id => @project}, :caption => 'PM Alerts'

I needed to make sure that the following line was in my config/routes.rb file:

get 'report', :to => 'report#index'

Hopefully this helps someone else out. I can't imagine that this is an uncommon problem for people porting plugins who are not great at ruby (or reading the minds of a computer, because you have to admit, throwing a 404 for this is a terrible error message).

EDIT: Originally I didn't have project_id => Herve Harster in my menu line. I added it after seeing this thread. I'm not sure if it is needed, but I suspect it is not.

    (1-4/4)