How can I check if the page is using a controllers action. for example i
got a helper method that needs to know if a certain controller action is
run on the page or not so as to display different content for it.
How can I check if the page is using a controllers action. for example i
got a helper method that needs to know if a certain controller action is
run on the page or not so as to display different content for it.
Thought it was just
code = "xyz" if Controllername.action?
Cheers,
Rog
--
Posted viahttp://www.ruby-forum.com/.
If I correctly understood what you need, you may try using:
Controller.action_methods.include?params[:action]
Where params[:action] will contain the slice of the url corresponding
to the action in the last request
How can I check if the page is using a controllers action. for example i
got a helper method that needs to know if a certain controller action is
run on the page or not so as to display different content for it.
Thought it was just
code = "xyz" if Controllername.action?
Your views have access to the controller and method that rendered them
via controller.controller_name and controller.action_name
e.g.,
<% if controller.controller_name == 'posts' %>
<% if controller.action_name == 'create' %>
<%= do whatever %>
<% end %>
<% end %>