Tbpgr Blog

Employee Experience Engineer tbpgr(てぃーびー) のブログ

Ruby on Rails | コントローラ、アクションの名前及びパスの取得

概要

コントローラ、アクションの名前及びパスの取得

内容

コントローラ、アクションの名前及びパスを取得します。

サンプル

app/controller/hoge_controller.rb

class HogeController < ApplicationController
  skip_before_filter :authorize

  def index
    @time = Time.now_msec
    @time_format = Time.now_msec_format

    @controller_name = controller_name
    @action_name = action_name
  end
end

app/view/hoge/index.html.haml

%p 
  time =
  =@time
%p 
  time_format =
  =@time_format
%p 
  controller_name =
  =@controller_name
%p 
  action_name =
  =@action_name

画面