Edit routes.rb to change mapping of home

Added by Thomas Evensen over 6 years ago

Hi,

I've managed to understand that I can use routes.rb to route calls to the "home"-page to e.g. the wiki page of one of my projects, but the file is kinda cryptic and so far I've only gotten as far as:

map.home '', :controller => 'projects', :action => 'show', :id => 'admin'

This only takes me to the overview-page of the project and not the wiki-page.

I guess this is what's done on redmine.org.

Any help on how to take it one step further?

Replies (2)

RE: Edit routes.rb to change mapping of home - Added by Thomas Evensen over 6 years ago

Hi,

After a lot of looking around, I found out that most of the documentation and issues refer to some wrong function calls (or what the name is).

What worked for me is the following:

map.home '', :controller => 'wiki', :project_id => 'admin', :action => 'show', :id => 'wiki'

RE: Edit routes.rb to change mapping of home - Added by Maximilian Lotz over 5 years ago

I just started again with Redmine 1.4.2 (was using some 0.9 the last time).

However, it seems that this "hack" will break Atom feeds and PDF.

my routes.rb

map.home '', :controller => 'projects', :conditions => {:method => :get}

When accessing Atomfeed:
Processing ProjectsController#index to atom (for x.x.x.x at 2012-05-19 13:25:56) [GET]
  Parameters: {"format"=>"atom", "action"=>"index", "controller"=>"projects"}
Rendering common/feed.atom

ActionView::TemplateError (No route matches {:controller=>"welcome", :action=>"index"}) on line #6 of app/views/common/feed.atom.builder:
3:   xml.title   truncate_single_line(@title, :length => 100)
4:   xml.link    "rel" => "self", "href" => url_for(params.merge(:only_path => false, :escape => false))
5:   xml.link    "rel" => "alternate", "href" => url_for(params.merge(:only_path => false, :format => nil, :key => nil, :escape => false))
6:   xml.id      url_for(:controller => 'welcome', :only_path => false)
7:   xml.updated((@items.first ? @items.first.event_datetime : Time.now).xmlschema)
8:   xml.author  { xml.name "#{Setting.app_title}" }
9:   xml.generator(:uri => Redmine::Info.url) { xml.text! Redmine::Info.app_name; }

    app/views/common/feed.atom.builder:6:in `_run_builder_app47views47common47feed46atom46builder'
    app/views/common/feed.atom.builder:2:in `_run_builder_app47views47common47feed46atom46builder'
    app/controllers/application_controller.rb:362:in `render_feed'
    app/controllers/projects_controller.rb:61:in `index'
    app/controllers/projects_controller.rb:49:in `index'
    /usr/lib/ruby/1.8/phusion_passenger/rack/request_handler.rb:92:in `process_request'
    /usr/lib/ruby/1.8/phusion_passenger/abstract_request_handler.rb:207:in `main_loop'
    /usr/lib/ruby/1.8/phusion_passenger/railz/application_spawner.rb:418:in `start_request_handler'
    /usr/lib/ruby/1.8/phusion_passenger/railz/application_spawner.rb:358:in `handle_spawn_application'
    /usr/lib/ruby/1.8/phusion_passenger/utils.rb:184:in `safe_fork'
    /usr/lib/ruby/1.8/phusion_passenger/railz/application_spawner.rb:354:in `handle_spawn_application'
    /usr/lib/ruby/1.8/phusion_passenger/abstract_server.rb:352:in `__send__'
    /usr/lib/ruby/1.8/phusion_passenger/abstract_server.rb:352:in `main_loop'
    /usr/lib/ruby/1.8/phusion_passenger/abstract_server.rb:196:in `start_synchronously'
    /usr/lib/ruby/1.8/phusion_passenger/abstract_server.rb:163:in `start'
    /usr/lib/ruby/1.8/phusion_passenger/railz/application_spawner.rb:213:in `start'
    /usr/lib/ruby/1.8/phusion_passenger/spawn_manager.rb:262:in `spawn_rails_application'
    /usr/lib/ruby/1.8/phusion_passenger/abstract_server_collection.rb:126:in `lookup_or_add'
    /usr/lib/ruby/1.8/phusion_passenger/spawn_manager.rb:256:in `spawn_rails_application'
    /usr/lib/ruby/1.8/phusion_passenger/abstract_server_collection.rb:80:in `synchronize'
    /usr/lib/ruby/1.8/phusion_passenger/abstract_server_collection.rb:79:in `synchronize'
    /usr/lib/ruby/1.8/phusion_passenger/spawn_manager.rb:255:in `spawn_rails_application'
    /usr/lib/ruby/1.8/phusion_passenger/spawn_manager.rb:154:in `spawn_application'
    /usr/lib/ruby/1.8/phusion_passenger/spawn_manager.rb:287:in `handle_spawn_application'
    /usr/lib/ruby/1.8/phusion_passenger/abstract_server.rb:352:in `__send__'
    /usr/lib/ruby/1.8/phusion_passenger/abstract_server.rb:352:in `main_loop'
    /usr/lib/ruby/1.8/phusion_passenger/abstract_server.rb:196:in `start_synchronously'
    /usr/lib/phusion_passenger/passenger-spawn-server:61

Rendering /usr/share/redmine/example/public/500.html (500 Internal Server Error)

So you have to edit more than just routes.rb.

Never really checked this on the older Redmine versions.

(1-2/2)