I am currently looking for a software/web development job preferably as a Rails-based developer.
Please email me at weston@westonganger.com. Thanks in advance for any leads!

Get Controller Name Or Action Name Of Previous Page In Rails

Posted by Weston Ganger

It can be helpful to know what controller or actions name the previous request had. This is a nice clean method to get that information.

Rails.application.routes.recognize_path(request.referrer) #=> {:controller => "posts", :action => "show"}

prev[:action] #=> "show"
prev = Rails.application.routes.recognize_path(request.referrer)
prev[:controller] #=> "posts"

Related External Links:

Article Topic:Software Development - Rails

Date:October 15, 2015

Recommended Posts