Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiple routing file in Rails 3

Rails 2.3 has an option to add more routes anytime using RouteSet#add_configuration_file.

Is it possible to do the same in a Rails 3 project?

like image 989
Amitava Avatar asked Feb 08 '11 08:02

Amitava


People also ask

How many types of routes are there in Rails?

Rails RESTful Design which creates seven routes all mapping to the user controller. Rails also allows you to define multiple resources in one line.

How do I see all routes in Rails?

Decoding the http request TIP: If you ever want to list all the routes of your application you can use rails routes on your terminal and if you want to list routes of a specific resource, you can use rails routes | grep hotel . This will list all the routes of Hotel.

What is match in Rails routes?

Rails routes are matched in the order they are specified, so if you have a resources :photos above a get 'photos/poll' the show action's route for the resources line will be matched before the get line. To fix this, move the get line above the resources line so that it is matched first.


1 Answers

in config/application.rb:

config.paths.config.routes << File.join(Rails.root, "config/routes/route_file.rb")

In Rails 3.2 (possibly also Rails 3.1), use:

config.paths["config/routes"] << Rails.root.join('config/routes/route_file.rb')

like image 100
Joe Van Dyk Avatar answered Sep 21 '22 04:09

Joe Van Dyk