before_filter not inheriting from parent controller correctly?
Posted
by
Scott
on Stack Overflow
See other posts from Stack Overflow
or by Scott
Published on 2011-01-02T03:10:04Z
Indexed on
2011/01/02
3:54 UTC
Read the original article
Hit count: 182
ruby-on-rails3
Sorry if this may be a stupid question but I'm unable get my filters to inherit the way the Rails 3 documentation is saying it should.
Specifically I have an Admin controller that was generated via:
rails generate controller admin
I added only a single action to the admin controller, the before filter & the private filter method
class AdminController < ApplicationController
before_filter require_admin_creds
def index
end
private
def require_admin_creds
unless current_user && current_user.admin?
flash[:error] = ...
redirect_to ....
end
end
end
I next then created my nested resources under the admin section with:
rails generate scaffold admin/model
While my admin index is indeed getting the filter, the admin/model index (or any other actions) are not. What is happening under the hood here that I must have excluded?
Thanks in advance.
© Stack Overflow or respective owner