2

How can I access the controller name inside a partial or a view thats rendered by the controller.

I want to create a dynamic template that changes depending on the controller rendering it, whats the best way to do it? I would prefer to access the controller inside the view rather than setting a new variable.

Jikku Jose
  • 18,306
  • 11
  • 41
  • 61

1 Answers1

2

There are two methods to detect the entry point in Padrino: request.controller and request.action.

controller :foo do
  get :bar do
    [request.controller, request.action].inspect
  end
end

=> ["foo", :bar]
ujifgc
  • 2,215
  • 2
  • 19
  • 21