# SHLG and lib dir

**URL:** <https://www.ruby-forum.com/t/shlg-and-lib-dir/53206>\
**Category:** Rails\
**Created:** [January 29, 2006, 1:22am UTC](https://www.ruby-forum.com/t/shlg-and-lib-dir/53206 "2006-01-29T01:22:28Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![glenatron](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/94ad74/32.png) [@glenatron](https://www.ruby-forum.com/u/glenatron)\
**Post date:** [January 29, 2006, 1:22am UTC](https://www.ruby-forum.com/t/shlg-and-lib-dir/53206/1 "2006-01-29T01:22:28Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![glenatron](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/94ad74/32.png) [@glenatron](https://www.ruby-forum.com/u/glenatron)\
**Post date:** [January 29, 2006, 9:14pm UTC](https://www.ruby-forum.com/t/shlg-and-lib-dir/53206/2 "2006-01-29T21:14:43Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![glenatron](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/94ad74/32.png) [@glenatron](https://www.ruby-forum.com/u/glenatron)\
**Post date:** [January 29, 2006, 10:42pm UTC](https://www.ruby-forum.com/t/shlg-and-lib-dir/53206/3 "2006-01-29T22:42:21Z")

</div>

Have you definitely 'require’d your member\_system.rb file somewhere?

---

<div class="post-metadata">

**Author:** ![glenatron](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/94ad74/32.png) [@glenatron](https://www.ruby-forum.com/u/glenatron)\
**Post date:** [January 29, 2006, 11:06pm UTC](https://www.ruby-forum.com/t/shlg-and-lib-dir/53206/4 "2006-01-29T23:06:25Z")

</div>

Ack! I knew it was something simple! thanks so much…

b
