Strangest restful_authentication 'unidentified method' error

Hi. My head is about to explode on this one.

I am using restful_authentication and added a method to
lib/authentication_system.rb like so:

module AuthenticatedSystem
protected
def logged_in?
current_user != :false
end

def role_at_least(role)
  return true
end


end

The method “logged_in?” that came with the plugin is always found and
works. But when I call role_at_least() it always returns:

undefined method `role_at_least’ for #<#Class:0x38909f4:0x38909cc>

I have pulled all my hair out and tried just about everything.
Restarted the webrick, tried mongrel, restarted my machine even…

If I remove the logged_in? definition I get the expected "undefined
method `logged_in?’ " message. I then put it back and it works
perfectly, but role_at_least has never been visible. I even tried
removing the parameter to see if it would make any difference but I
similarily get:

undefined local variable or method `role_at_least’ for
#<#Class:0x39efc28:0x39efc00>

I would really appreciate any help or tips on how I can further debug
this.

Thanks, Chad.

On 16 Aug 2007, at 16:21, Chad T. wrote:

method `logged_in?’ " message. I then put it back and it works
perfectly, but role_at_least has never been visible. I even tried
removing the parameter to see if it would make any difference but I
similarily get:

undefined local variable or method `role_at_least’ for
#<#Class:0x39efc28:0x39efc00>

I would really appreciate any help or tips on how I can further debug
this.

Look a bit further in the code:

 def self.included(base)
   base.send :helper_method, :current_user, :logged_in?
 end

You’ll need to add your role_at_least method to this list. This
includes the methods as ActionView helper methods.

Best regards

Peter De Berdt

Thanks Peter, that solved my problem. I feel like a bit of an idiot
because I did grep the source tree for logged_in? to see where else it
may be being declared or otherwise used but I completely missed it in
“included”. Going to go brush up on modules in Ruby now :slight_smile: