ruby on rails - LoadError in UsersController#create -



ruby on rails - LoadError in UsersController#create -

to provide background info, i've been next michael hartls 'learning rails' tutorial via livelessons , i've made "lesson 8 - sign success". although problem quite specific, hope post useful others next along tutorial if brought halt similar error. (note: wasn't able find specific problem anywhere on stack, goal here shed lite on help!)

now meat , potatos (when trying sign up, i'm redirected localhost:3000/users , following:

loaderror in userscontroller#create library not found class digest::shaz2 -- digest/shaz2

rails.root: /users/anthonypanepinto/sites/rails_projects/sample_app1

app/models/user.rb:57:in `secure_hash' app/models/user.rb:53:in `make_salt' app/models/user.rb:44:in `encrypt_password' app/controllers/users_controller.rb:15:in `create' request parameters: {"utf8"=>"✓", "authenticity_token"=>"/seaqnrmf5x0pd4fvwbu8uwvajtnw4lpkixg+8hl0pq=", "user"=>{"name"=>"anth", "email"=>"pane@example.com", "password"=>"[filtered]", "password_confirmation"=>"[filtered]"}, "commit"=>"sign up"}

here contents of users_controller.rb

class userscontroller < applicationcontroller def show @user = user.find(params[:id]) @title = @user.name end def new @user = user.new @title = "sign up" end def create @user = user.new(params[:user]) if @user.save redirect_to @user, :flash => { :success => "welcome fun house!" } else @title = "sign up" render 'new' end end end

my user.rb file

class user < activerecord::base attr_accessor :password attr_accessible :email, :name, :password, :password_confirmation email_regex = /\a[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i validates :name, :presence => true, :length => { :maximum => 50 } validates :email, :presence => true, :format => { :with => email_regex }, :uniqueness => { :case_sensitive => false } validates :password, :presence => true, :confirmation => true, :length => { :within => 6..40 } before_save :encrypt_password def has_password?(submitted_password) encrypted_password == encrypted(submitted_password) end class << self def user.authenticate(email, submitted_password) user = find_by_email(email) homecoming nil if user.nil? homecoming user if user.has_password?(submitted_password) end end private def encrypt_password self.salt = make_salt if new_record? self.encrypted_password = encrypt(password) end def encrypt(string) secure_hash("#{salt}--#{string}") end def make_salt secure_hash("#{time.now.utc}--#{password}") end def secure_hash(string) digest::shaz2.hexidigest(string) end end

and show.html.erb file

<table class="profile" summary="profile information"> <tr> <td class="main"> <h1> <%= gravatar_for @user %> <%= @user.name %> </h1> </td> <td class="sidebar round"> <strong>name</strong> <%= @user.name %><br /> <strong>url</strong> <%= link_to user_path(@user), @user %> </td> </tr> </table>

and lastly _error_messages.html.erb file

<% if @user.errors.any? %> <div id="error_explanation"> <h2> <%= pluralize(@user.errors.count, "error") %> prohibited user beingness saved: </h2> <p>there problems next fields:</p> <ul> <% @user.errors.full_messages.each |message| %> <li><% message %></li> <% end %> </ul> </div> <% end %>

ruby-on-rails ruby controller user

Comments

Popular posts from this blog

web services - java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer -

Accessing MATLAB's unicode strings from C -

javascript - mongodb won't find my schema method in nested container -