Hi everyone, I’m new to rails.
My application has 3 modules: Admin, Xml, Flash.
I wrote a before_filter in the application.rb that check if the user is
authenticate (my own, not the plugins). Everything work right, but now
that I split my apps in 3 modules, I don’t know how to apply the
security just on the Admin module.
Of course, I can add the before_filter in each controller under Admin
module, But I looking for a global way to do it. I would like to don’t
have to add the filter on each new controller of the Admin module.
Is there a way of doiing this?
Thanks
P.S. Sorry for the bad english. I’m french
Carl Pelletier wrote:
I wrote a before_filter in the application.rb that check if the user is
authenticate (my own, not the plugins). Everything work right, but now
that I split my apps in 3 modules, I don’t know how to apply the
security just on the Admin module.
Of course, I can add the before_filter in each controller under Admin
module, But I looking for a global way to do it. I would like to don’t
have to add the filter on each new controller of the Admin module.
Is there a way of doiing this?
Create a base class for all your admin controllers and add your
before_filter to that. Then you can inherit from the base class to use
the authentication.
class Admin::BaseController < ApplicationController
before_filter :do_authentication
end
class Admin::MyAdminController < Admin::BaseController
end
–
Phil Ross
http://tzinfo.rubyforge.org/ – DST-aware timezone library for Ruby