I have a new, mountable rails 3.1 engine and I need the client app, that being the rails app that will include this engine, to define a generic permission based method.
So, what I want is in my engine's blog controller to say something like:
before_filter :redirect_unless_admin
And then I want to leave it to the client app to define who is an admin. However, whenever I try this I get:
NameError in Blog::BlogsController#show
undefined local variable or method `redirect_unless_admin' for #<Blog::BlogsController:0x000001058aa038>
My client app controller looks something like this:
class ApplicationController < ActionController::Base
# Required by blog engine
def redirect_unless_admin
if !logged_in?
set_session_redirect
redirect_to login_path, :notice => 'Please log in.'
elsif !current_user.admin?
set_session_redirect
redirect_to root_path, :notice => 'You do not have permission to view this page.'
end
end
And in my engine app controller, I have the following:
module Blog
class ApplicationController < ActionController::Base
end
end
Can somebody tell me how to set it up so that my engine's blog controller can talk to my client's application_controller?