-2

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

xiatica
  • 1,546
  • 2
  • 20
  • 24

1 Answers1

0

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
scs
  • 119
  • 7
  • If it's Rails < v4, you may need to do `match 'controller/:id/action' => 'controller#action', via: :get` – Jaeger Jan 06 '17 at 08:22