How to change landing page via plugin in Redmine 3.2.3 ?
Added by Lennart Nordgreen over 8 years ago
Hi there.
First om all I am not a Ruby (on Rails) guru so I apologizes in advance for may lack of wisdom in this realm.
Environment¶
RHEL 7 ruby -v ruby 2.1.6p336 (2015-04-13 revision 50298) [x86_64-linux] gem -v 2.2.3 passenger -v Phusion Passenger 5.0.30 rails -v Rails 4.2.5.2 httpd -v Server version: Apache/2.4.6 (Red Hat Enterprise Linux) Server built: Jul 12 2016 05:02:54
The problem¶
Prior to Redmine version 3.2.3 I've used this to change the landing page but this doesn't work anymore.
Can someone shed some light on how to do this i 3.x?
init.rb
RedmineApp::Application.routes.prepend do
scope '/home' do
resources :welcome
end
match '/', :to => 'issues#index', :as => 'home', :via => [:get]
match '/home', :to => 'welcome#index', :via => [:get]
#root :to => 'issues#index', :via => :get, :as => 'home'
end
Redmine::MenuManager.map :top_menu do |menu|
menu.push 'Home', "/home", { :first => true, :caption => 'Hjem'}
end
Error message as follows.
ArgumentError: Invalid route name, already in use: 'home' You may have defined two routes with the same name using the `:as` option, or you may be overriding a route already defined by a resource with the same naming. For the latter, you can restrict the routes created with `resources` as explained here: http://guides.rubyonrails.org/routing.html#restricting-the-routes-created
Also, only specifying -> root :to => 'issues#index', :via => :get, :as => 'home' doesn't work either.
RedmineApp::Application.routes.prepend do
root :to => 'issues#index', :via => :get, :as => 'home'
end
Any ideas?
Thanks.
Replies (3)
RE: How to change landing page via plugin in Redmine 3.2.3 ? - Added by Akiko Takano about 8 years ago
Hello!
I’m interested this feature to overwrite routing via plugin, thanks for your posting :)
BTW, in my local Redmine, which version is Redmine 3.3.0, I could change landing page with this code:
RedmineApp::Application.routes.prepend do
scope '/home' do
resources :welcome
end
match '/', :to => 'issues#index', :via => [:get]
end
Redmine::MenuManager.map :top_menu do |menu|
menu.push 'Home', "/home", { :first => true, :caption => 'Hjem'}
end
How about?
RE: How to change landing page via plugin in Redmine 3.2.3 ? - Added by Lennart Nordgreen about 8 years ago
Yes that works but it also makes the default Home page (which I like to bind to /home) unavailable.
The problem is if I use as => home or to => welcome#index it fails since these routes are already in use.
Strange you can't add your own links to whatever resource you'd like, or it is possible but I don't know how to do it.
RE: How to change landing page via plugin in Redmine 3.2.3 ? (WORKAROUND/SOLVED) - Added by Lennart Nordgreen about 8 years ago
Managed to do a workaround by using redmine_my_page plugin so the users can choose them selves which start page to use.
https://github.com/jrupesh/redmine_my_page
Thanks!