views:

554

answers:

2

Hi all,

I want to write a before_filter in my controller to identify the action which will execute next. This is for authorization purposes (this is somewhat like role_requirement plugin do..)

Ex: if a user types this url http://localhost:3000/users, default it goes to users/index action. And in my users controller i'm having a before filter method say 'check_permission' and i want that method to get 'index' as the action

thanks in advance

cheers, sameera

A: 

I believe you want to call path_parameters on the request object and then grab the action from the hash returned.

Rob Di Marco
+1  A: 

The action_name method on the controller should give you what you're looking for. It's not documented, though, so there is no guarantee it won't disappear someday.

before_filter { |controller| logger.debug "Running before the #{controller.action_name} action" }
Steve Madsen
thanks Steve, surly looks promising I'll check it out cheers,sameera
sameera207