Hi, so I''ve got my nice pagination module that I''m mixing into application.rb. It all works really nice, except for my before_filter definition: When I put it into the module, my app starts throwing 500- errors. Obviously I can''t add this from a module the way I''m calling it directly in application.rb or specific controllers, because the before_filter class method seems to be out of scope or something. Is there a way to achieve this some other way? Thanks in advance and greetings, Christoph --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Really no ideas on how to do this? On 24 Jun., 03:05, Christoph Olszowka <musicpo...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> Hi, > > so I''ve got my nice pagination module that I''m mixing into > application.rb. It all works really nice, except for my before_filter > definition: When I put it into the module, my app starts throwing 500- > errors. Obviously I can''t add this from a module the way I''m calling > it directly in application.rb or specific controllers, because the > before_filter class method seems to be out of scope or something. Is > there a way to achieve this some other way? > > Thanks in advance and greetings, > Christoph--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Christoph Olszowka wrote:> so I''ve got my nice pagination module that I''m mixing into > application.rb. It all works really nice, except for my before_filter > definition: When I put it into the module, my app starts throwing 500- > errors. Obviously I can''t add this from a module the way I''m calling > it directly in application.rb or specific controllers, because the > before_filter class method seems to be out of scope or something. Is > there a way to achieve this some other way?Hard to say what''s going on w/o seeing any of your code. This is how I would do it: module Foo def self.included(base) base.before_filter :bar end def bar # ... end end -- Josh Susser http://blog.hasmanythrough.com -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
You can also use ActiveRecord::Concer and put model related methods to included block. For example: require ''active_support/concern'' module Foo extend ActiveSupport::Concern included do before_filter :bar end end --- Artur Małecki http://seeweer.com -- Posted via http://www.ruby-forum.com/. -- 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@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.