Hello, I was wondering if anybody can show me how to pass parameters to a Private method with before_filter. I''ve tried doing the proc blocked way with before_filter {|c| c.private_method(params)} ...but this throws an exception when the method is private. The rails api says that using the standard symbol reference ( before_filter :private_method) is for private and protected methods which leads me to assume that using the block method only works for public methods. Does anybody know how I might pass parameters to a private method with before_filter? Thanks Greg T. --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Bob Showalter
2007-Nov-15 19:02 UTC
Re: passing parameters to private methods with before_filter
On Nov 15, 2007 1:55 PM, gete <greg.traub-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Hello, > > I was wondering if anybody can show me how to pass parameters to a > Private method with before_filter. > I''ve tried doing the proc blocked way with > > before_filter {|c| c.private_method(params)} ...but this throws an > exception when the method is private.You can use send: c.send(:private_method, params) --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hi Bob, That worked....thanks so much. Greg On Nov 15, 2:02 pm, "Bob Showalter" <showa...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Nov 15, 2007 1:55 PM, gete <greg.tr...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > Hello, > > > I was wondering if anybody can show me how to pass parameters to a > > Private method with before_filter. > > I''ve tried doing the proc blocked way with > > > before_filter {|c| c.private_method(params)} ...but this throws an > > exception when the method is private. > > You can use send: > > c.send(:private_method, params)--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---