Forum: Ruby on Rails NameError: uninitialized constant Digest::SHA2

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Sav (Guest)
on 2008-12-27 17:44
(Received via mailing list)
I'm migrating a working app to a new server, but all my authentication
tests are failing on SHA2.  The user.rb model has require 'digest/
sha2' at the top, yet I still get this error...

NameError: uninitialized constant Digest::SHA2

Any ideas how to resolve this issue?  I've been searching Google for a
day and haven't found anything.

Here is some more info on my new setup (running Debian etch)...

# ruby -v
ruby 1.8.5 (2006-08-25) [i486-linux]

# rails -v
Rails 2.2.2

# gem -v

# gem list --local

*** LOCAL GEMS ***

actionmailer (2.2.2, 2.0.2)
actionpack (2.2.2, 2.0.2)
activerecord (2.2.2, 2.0.2)
activeresource (2.2.2, 2.0.2)
activesupport (2.2.2, 2.0.2)
cgi_multipart_eof_fix (2.5.0)
daemons (1.0.10)
fastthread (1.0.1)
gem_plugin (0.2.3)
hoe (1.8.2)
jruby-openssl (0.3)
memcache-client (1.5.0)
mongrel (1.1.5)
mongrel_cluster (1.0.5)
rails (2.2.2, 2.0.2)
rake (0.8.3)
ruby-openid (2.1.2)
rubyforge (1.0.1)
youtube-g (
ZenTest (3.11.0)
Sav (Guest)
on 2008-12-27 21:08
(Received via mailing list)
Ouch - I simply used Digest::SHA256 instead of Digest::SHA2 and it
works now.
karthik (Guest)
on 2008-12-29 12:28
(Received via mailing list)
Just try the echo statement and check what it is printing in the
model.May be the sha1 will be using function also in addtion
to its own coding.The time that value is authenticated and the time
when u are checking the authentication will be different

The solution is if the sha1 is encoded with time also just remove the function from it.Then this will solve the issue.i have also
faced the similar problem when i used acts_as_authenticated plugin.
This topic is locked and can not be replied to.