Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how get all routes in my rails application?

Tags:

can I get all routes in my rails application? I need an output like rake routes and put the result in an array.

Is it possible? how?

like image 882
el_quick Avatar asked Sep 08 '10 23:09

el_quick


People also ask

How do I see all routes in Rails?

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.

Which command typed at command line will list all of the app's routes?

bin/rails routes will list all of your defined routes, which is useful for tracking down routing problems in your app, or giving you a good overview of the URLs in an app you're trying to get familiar with.

How do routes work in Rails?

Rails routing is a two-way piece of machinery – rather as if you could turn trees into paper, and then turn paper back into trees. Specifically, it both connects incoming HTTP requests to the code in your application's controllers, and helps you generate URLs without having to hard-code them as strings.

What are the 7 CRUD routes generated by the resources Method resources songs in Rails?

In Rails, there are seven standard CRUD actions: index, show, new, create, edit, update, and destroy, which relate to specific HTTP verbs and are usually implemented using specific ActiveRecord methods.


1 Answers

You could have a look at way rails spits out those routes from the rake task. It's in /gems/rails/2.3.x/lib/tasks/routes.rake for Rails 2. Seems to be basically doing ActionController::Routing::Routes.routes in the general case and then interrogating that.

like image 73
Shadwell Avatar answered Sep 23 '22 05:09

Shadwell