I found a solution to my problem:
The require line should be in environment.rb and then everything works
perfectly (the include stays in application.rb).
Ben
On 5/23/05, Ben Myles <ben.myles-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> Hi,
>
> I''m trying to "mixin" a module into my
ApplicationController class so
> that my other controllers which inherit ApplicationController will get
> the methods in my module.
>
> I''m having some trouble getting things to work. My application.rb
and
> bsecure.rb file contents are pasted below. Ruby seems to find my
> module okay, but the method doesn''t appear to any of my
controllers. I
> just get (for example):
>
> undefined method `authenticate'' for
#<UserController:0x2445c70>
>
> Any help as to where I''ve fell off the rails is greatly
appreciated!
>
> Ben
>
> --------
>
> require "bsecure.rb"
>
> class ApplicationController < ActionController::Base
> include BSecure
> before_filter :authenticate
> end
>
> ----
>
> module BSecure
> def authenticate
> render_text "authenticate"
> end
> end
>