Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

rails 3 route alias

In older version 2.x I was doing something like:

map.resources :jobs, :as => 'vagas'

and this way, I can use jobs_path to create a link to.

But in rails 3, I still can use :as to define an alias, but I cannot use jobs_path anymore, because it forces me to use vagas_path.

So I was wondering if have any way to define an alias and still use the original resource name to create a link.

like image 867
Kleber S. Avatar asked Mar 09 '11 00:03

Kleber S.


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?

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 are nested routes in Rails?

In a nested route, the belongs_to (child) association is always nested under the has_many (parent) association. The first step is to add the nested routes like so: In the above Rails router example, the 'index' and 'show' routes are the only nested routes listed (additional or other resources can be added).


1 Answers

resources :jobs, :path => 'vagas'  # after the original!
like image 147
vise Avatar answered Sep 18 '22 14:09

vise