Can Ruby on Rails Routes point a nested URL at a single action?

99 views Asked by At

Is it possible in Ruby on Rails (we're using v2 still) to allow the routes file to map a nested url EG

mydomain.com/controller/object/action

to a single action eg

:controller, :action

?

We currently have a url like mydomain.com/controller/action and i want to change it to mydomain.com/controller/object/action

Thanks in advance

1

There are 1 answers

1
scs On

You can write singular route like as follow. You will get record id in params[:id] in controller action.

match 'controller/:id/action' => 'controller#action', via: :get