Hi! I''m Matheus Here''s the thing: I want to use :before_filter with the option :only using a function that returns a array of actions. For example: :before_filter :authorization, :only => :actions_i_want def actions_i_want [:new, :destroy, :create] end Please, if anyone know how to fix this, or another way to do it, help me!! Thanks -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 13 Jan 2011, at 01:34, Matheus Camargo <matheusfc09-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi! I''m Matheus > > Here''s the thing: I want to use :before_filter with the option :only > using a function that returns a array of actions. > > For example: > > :before_filter :authorization, :only => :actions_i_want > > def actions_i_want > [:new, :destroy, :create] > end > > Please, if anyone know how to fix this, or another way to do it, help > me!! >Don''t think rails supports this. You could always drop the :only option and then check the action yourself from your filter method Fred> Thanks > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Wednesday, January 12, 2011 8:34:15 PM UTC-5, Matheus Camargo wrote:> > Hi! I''m Matheus > > Here''s the thing: I want to use :before_filter with the option :only > using a function that returns a array of actions. > > For example: > > :before_filter :authorization, :only => :actions_i_want > > def actions_i_want > [:new, :destroy, :create] > end > > Please, if anyone know how to fix this, or another way to do it, help > me!! > > ThanksLike Frederick said, I''m pretty sure Rails doesn''t support this. Try his suggestion, eg: before_filter :authorization def authorization return unless %w(new destroy create).include? params[:action] # ...the rest of your code... end -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.