문제

Is there a way to get the currently executing controller and action name in Ramaze?

require 'ramaze'

class FooController < Ramaze::Controller
  def bar
    "#{controller}.#{action}" #how to get this to work?
  end
end

PS: I know self.class.name would give you the class name/controller name but was wondering if this captured somewhere else in the Ramaze API. Also __method__ should give the action name but I don't want to create variables when I pass this info to templates.

도움이 되었습니까?

해결책

You can get them with :

controller = action.node
method = action.method

See https://github.com/Ramaze/ramaze/wiki/Knowing-which-controller-or-method-triggered-view-layout-rendering

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top