You need a before_filter.

http://edgeguides.rubyonrails.org/action_controller_overview.html#filters



Dheeraj Kumar


On Saturday 12 May 2012 at 5:53 AM, Lauro Caetano wrote:

> Hi! 
> 
> I'm a RoR beginner and I'm trying to make a gem that can "intercepts" all 
> action from my controllers.
> 
> I would like to do something like that:
> 
> class ApplicationController < ActionController::Base
>   include MyGem
> end
> 
> class MyController < ApplicationController
>   do_something_to :some_attribute
> 
>   def index
>     respond_with(@some_attribute)
>   end
> end
> 
> In each call of index or other action from MyController, I want that MyGem 
> execute "do_something_to" modifying the value of "some_attribute". Is it 
> possible?
> 
> Thanks,
> Lauro Caetano
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Ruby on Rails: Talk" group.
> To post to this group, send email to rubyonrails-talk@googlegroups.com 
> (mailto:rubyonrails-talk@googlegroups.com).
> To unsubscribe from this group, send email to 
> rubyonrails-talk+unsubscr...@googlegroups.com 
> (mailto:rubyonrails-talk+unsubscr...@googlegroups.com).
> For more options, visit this group at 
> http://groups.google.com/group/rubyonrails-talk?hl=en.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to