Ruby on Rails Monday, September 29, 2014

I have something like this:



=========================================================================
class ApplicationController < ActionController::Base
def check_auth
# ...
end
end

class BaseController < ApplicationController
before_filter :check_auth, :except => [ :getSession ]
# more here...
def getSession()
# ...
end
end

class UserController < BaseController
before_filter :check_auth, :except => [ :getNotifications ]
# more here...
def getNotifications()
getSession()
# ...
end
end
=========================================================================

I'm was expecting wrongly that if UserController#getNotifications calls
BaseController#getSession check_auth would not called.

If I change the before_filter in my UserController to:

before_filter :check_auth, :except => [ :getSession, :getNotifications
]

it works as expected.

Isn't there a way to incorporate the before_filter settings from the
parent controller say during construction of an instance of a sub class?

Thanks for any help in advance
Pete

--
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 unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/ac2a0254bb2dbdc5eb5fbbb299bbc5e3%40ruby-forum.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment