Get the controller name and action name in a view
I'd normally do the following to know the controller and action in a defined view:
<%= params[:controller] %>
<%= params[:action] %>
Just today, found out there are two other (easier) ways to get those values:
<%= controller_name %>
<%= action_name %>
See docs for controller_name
Written by cesc1989
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Ruby
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#