70
61

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

[Rails 4.x] ViewからController名やAction名を参照する方法

Posted at

View(erb)からController名を参照する

<%= controller.controller_name %>

View(erb)からAction名を参照する

<%= controller.action_name %>

ついでに

Controllerから取得する

controller_name = controller_name  # コントローラ名
action_name = action_name  # アクション名

参考

70
61
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
70
61

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?