Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get request's target controller and action with Rails 3?

In the application controller before filter.

class ApplicationController < ActionController::Base   before_filter :authenticate    def authenticate     # How do we know which controller and action was targetted?   end end 
like image 677
randomguy Avatar asked Mar 24 '11 11:03

randomguy


1 Answers

class ApplicationController < ActionController::Base   before_filter :authenticate    def authenticate     # How do we know which controller and action was targetted?     params[:controller]     params[:action]     # OR     controller.controller_name     controller.action_name       end end 
like image 140
fl00r Avatar answered Sep 24 '22 23:09

fl00r