Slowly figuring out how to get my SaltedHashLoginGenerator stuff working. The wiki page says to put "before_filter :login_required" in the user (my "user" is "member") controller or in ApplicationController. However, wherever I put it I get NoMethodError. The rest of the SHLG stuff seems to be working... or at least I could get to the signup page, register, and confirm my registration from the email it sent. But the login_required method -- which is in my member_system.rb ("member" is my "user") -- can''t be found. Hmm, although, I notice that the MemberSystem module has "protected" at the top... that means everything below is protected, right? Would that cause a problem? (that''s the way it was generated though, so I doubt it) Here''s my ApplicationController: class ApplicationController < ActionController::Base include Localization include MemberSystem helper :member model :member before_filter :login_required end And here''s some of the lib/member_system.rb: module MemberSystem protected ... # login_required filter. add # # before_filter :login_required # # if the controller should be under any rights management. # for finer access control you can overwrite # # def authorize?(member) # def login_required if not protect?(action_name) return true end if member? and authorize?(@session[''member'']) return true end # store current location so that we can # come back after the user logged in store_location # call overwriteable reaction to unauthorized access access_denied return false end ... Any ideas? thanks, b
Please excuse the ping... allow me to be more terse: What would cause a method in a module under /lib to not be found? The method exists and module *is* included in the class that''s trying to call it. The method is protected, but I just tried it as public and the method still can''t be found. Any and all ideas very welcome. b Ben Munat wrote:> Slowly figuring out how to get my SaltedHashLoginGenerator stuff > working. The wiki page says to put "before_filter :login_required" in > the user (my "user" is "member") controller or in ApplicationController. > However, wherever I put it I get NoMethodError. > > The rest of the SHLG stuff seems to be working... or at least I could > get to the signup page, register, and confirm my registration from the > email it sent. But the login_required method -- which is in my > member_system.rb ("member" is my "user") -- can''t be found. > > Hmm, although, I notice that the MemberSystem module has "protected" at > the top... that means everything below is protected, right? Would that > cause a problem? (that''s the way it was generated though, so I doubt it) > > Here''s my ApplicationController: > > class ApplicationController < ActionController::Base > include Localization > include MemberSystem > > helper :member > model :member > > before_filter :login_required > > end > > And here''s some of the lib/member_system.rb: > > module MemberSystem > > protected > > ... > > # login_required filter. add > # > # before_filter :login_required > # > # if the controller should be under any rights management. > # for finer access control you can overwrite > # > # def authorize?(member) > # > def login_required > > if not protect?(action_name) > return true > end > > if member? and authorize?(@session[''member'']) > return true > end > > # store current location so that we can > # come back after the user logged in > store_location > > # call overwriteable reaction to unauthorized access > access_denied > return false > end > > ... > > Any ideas? > > thanks, > > b > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails
Have you definitely ''require''d your member_system.rb file somewhere? On 1/29/06, Ben Munat <bent@munat.com> wrote:> Please excuse the ping... allow me to be more terse: > > What would cause a method in a module under /lib to not be found? > > The method exists and module *is* included in the class that''s trying to call it. The > method is protected, but I just tried it as public and the method still can''t be found. > > Any and all ideas very welcome. > > b > > Ben Munat wrote: > > Slowly figuring out how to get my SaltedHashLoginGenerator stuff > > working. The wiki page says to put "before_filter :login_required" in > > the user (my "user" is "member") controller or in ApplicationController. > > However, wherever I put it I get NoMethodError. > > > > The rest of the SHLG stuff seems to be working... or at least I could > > get to the signup page, register, and confirm my registration from the > > email it sent. But the login_required method -- which is in my > > member_system.rb ("member" is my "user") -- can''t be found. > > > > Hmm, although, I notice that the MemberSystem module has "protected" at > > the top... that means everything below is protected, right? Would that > > cause a problem? (that''s the way it was generated though, so I doubt it) > > > > Here''s my ApplicationController: > > > > class ApplicationController < ActionController::Base > > include Localization > > include MemberSystem > > > > helper :member > > model :member > > > > before_filter :login_required > > > > end > > > > And here''s some of the lib/member_system.rb: > > > > module MemberSystem > > > > protected > > > > ... > > > > # login_required filter. add > > # > > # before_filter :login_required > > # > > # if the controller should be under any rights management. > > # for finer access control you can overwrite > > # > > # def authorize?(member) > > # > > def login_required > > > > if not protect?(action_name) > > return true > > end > > > > if member? and authorize?(@session[''member'']) > > return true > > end > > > > # store current location so that we can > > # come back after the user logged in > > store_location > > > > # call overwriteable reaction to unauthorized access > > access_denied > > return false > > end > > > > ... > > > > Any ideas? > > > > thanks, > > > > b > > _______________________________________________ > > Rails mailing list > > Rails@lists.rubyonrails.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
Ack! I knew it was something simple! thanks so much... b James Adam wrote:> Have you definitely ''require''d your member_system.rb file somewhere? > > On 1/29/06, Ben Munat <bent@munat.com> wrote: > >>Please excuse the ping... allow me to be more terse: >> >>What would cause a method in a module under /lib to not be found? >> >>The method exists and module *is* included in the class that''s trying to call it. The >>method is protected, but I just tried it as public and the method still can''t be found. >> >>Any and all ideas very welcome. >> >>b >> >>Ben Munat wrote: >> >>>Slowly figuring out how to get my SaltedHashLoginGenerator stuff >>>working. The wiki page says to put "before_filter :login_required" in >>>the user (my "user" is "member") controller or in ApplicationController. >>>However, wherever I put it I get NoMethodError. >>> >>>The rest of the SHLG stuff seems to be working... or at least I could >>>get to the signup page, register, and confirm my registration from the >>>email it sent. But the login_required method -- which is in my >>>member_system.rb ("member" is my "user") -- can''t be found. >>> >>>Hmm, although, I notice that the MemberSystem module has "protected" at >>>the top... that means everything below is protected, right? Would that >>>cause a problem? (that''s the way it was generated though, so I doubt it) >>> >>>Here''s my ApplicationController: >>> >>>class ApplicationController < ActionController::Base >>> include Localization >>> include MemberSystem >>> >>> helper :member >>> model :member >>> >>> before_filter :login_required >>> >>>end >>> >>>And here''s some of the lib/member_system.rb: >>> >>>module MemberSystem >>> >>> protected >>> >>> ... >>> >>> # login_required filter. add >>> # >>> # before_filter :login_required >>> # >>> # if the controller should be under any rights management. >>> # for finer access control you can overwrite >>> # >>> # def authorize?(member) >>> # >>> def login_required >>> >>> if not protect?(action_name) >>> return true >>> end >>> >>> if member? and authorize?(@session[''member'']) >>> return true >>> end >>> >>> # store current location so that we can >>> # come back after the user logged in >>> store_location >>> >>> # call overwriteable reaction to unauthorized access >>> access_denied >>> return false >>> end >>> >>> ... >>> >>>Any ideas? >>> >>>thanks, >>> >>>b >>>_______________________________________________ >>>Rails mailing list >>>Rails@lists.rubyonrails.org >>>http://lists.rubyonrails.org/mailman/listinfo/rails >> >>_______________________________________________ >>Rails mailing list >>Rails@lists.rubyonrails.org >>http://lists.rubyonrails.org/mailman/listinfo/rails >> > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails