Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I rake the routes for a specific resource?

I've been grepping the output of rake routes forever and it just dawned on me that someone must know a better way to inspect routes. I have a resource in my routes.rb name account_groups:

resources :account_groups 

Is there anyway to tell rake routes to only return the routes associated with this resource?

like image 549
spinlock Avatar asked Jul 29 '14 22:07

spinlock


People also ask

What are resource routes?

Resource routing allows you to quickly declare all of the common routes for a given resourceful controller. A single call to resources can declare all of the necessary routes for your index , show , new , edit , create , update , and destroy actions.

What does rake routes do?

rake 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 you define a route in Ruby?

We have to define the routes for those actions which are defined as methods in the BookController class. Open routes. rb file in library/config/ directory and edit it with the following content. The routes.


1 Answers

You can check for routes of specific controller:
rake routes CONTROLLER=account_groups

As seen in @ZiiCEagle's answer this is deprecated now and you should use
rails routes -c account_groups

like image 80
Doguita Avatar answered Sep 22 '22 01:09

Doguita