# Please help me decipher an error message

**URL:** <https://www.ruby-forum.com/t/please-help-me-decipher-an-error-message/109597>\
**Category:** Rails\
**Created:** [July 17, 2007, 7:58am UTC](https://www.ruby-forum.com/t/please-help-me-decipher-an-error-message/109597 "2007-07-17T07:58:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![wlefevre](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/71e660/32.png) [@wlefevre](https://www.ruby-forum.com/u/wlefevre)\
**Post date:** [July 17, 2007, 7:58am UTC](https://www.ruby-forum.com/t/please-help-me-decipher-an-error-message/109597/1 "2007-07-17T07:58:26Z")

</div>

Hello,  
I am adding a basic authentication scheme to my application. When I  
go to the console and try to add a new User I’m getting an error which I  
don’t know what to do with. Any help would be wonderful.

Here’s my console session:

> > u = User.new  
> > =\> #\<User:0x32f8aac @attributes={“username”=\>nil, “password”=\>nil},  
> > @new\_record=true\>
> 
> > u.password = ‘test’  
> > NameError: uninitialized constant User::MD5  
> > from  
> > /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active\_support/dependencies.rb:477:in  
> > `const_missing' from ./script/../config/../config/../app/models/user.rb:16:in`password=’  
> > from (irb):2
> 
> >

Here’s my User model:

class User \< ActiveRecord::Base

require ‘digest/md5’

def self.authenticate(name, password)  
user = User.find(:first,  
:conditions =\> [“name = ? AND password = ?”,  
name, MD5.md5(password).hexdigest])  
if user.blank?  
raise “Name or password is invalid”  
end  
user  
end

def password=(pswd)  
self.password = MD5.md5(pswd).hexdigest  
end

end

I think it’s not finding the digest/md5 file. If that’s the case I’m not  
really sure how to remedy that.

Thanks,  
William

---

<div class="post-metadata">

**Author:** ![wlefevre](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/71e660/32.png) [@wlefevre](https://www.ruby-forum.com/u/wlefevre)\
**Post date:** [July 19, 2007, 1:11am UTC](https://www.ruby-forum.com/t/please-help-me-decipher-an-error-message/109597/2 "2007-07-19T01:11:53Z")

</div>

replace

MD5.md5(‘password’).hexdigest

with

Digest::MD5.hexdigest(‘password’)

---

<div class="post-metadata">

**Author:** ![wlefevre](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/71e660/32.png) [@wlefevre](https://www.ruby-forum.com/u/wlefevre)\
**Post date:** [July 19, 2007, 8:50am UTC](https://www.ruby-forum.com/t/please-help-me-decipher-an-error-message/109597/3 "2007-07-19T08:50:59Z")

</div>

Chris H. wrote:

> replace
> 
> MD5.md5(‘password’).hexdigest
> 
> with
> 
> Digest::MD5.hexdigest(‘password’)

Thank you. That did the trick.

I’m not sure why the syntax changed. I copied  
'MD5.md5(‘password’).hexdigest, from a test site I did over a year ago  
which worked just fine.
