ruby on rails - undefined method `salt=' -


i trying add password thing website. when sign account, page shows after press sign button error page showing:

undefined method salt=' #<user:0x37f8168> app/models/user.rb:34:inencrypt_password' app/controllers/users_controller.rb:19:in `create'

in user.rb have:

def encrypt_password       self.salt = make_salt if new_record?       self.encrypted_password = encrypt(password)     end      def encrypt(string)       secure_hash("#{salt}--#{string}")     end 

in users_controller.rb have

def create     @user = user.new(params[:user])     if @user.save       sign_in @user       flash[:success] = "welcome penntwit"       redirect_to @user     else       @title = "sign up"       render 'new'     end   end 

the error lines:

if @user.save  self.salt = make_salt if new_record? 

i tried changing self.salt @salt gave me error saying salt in

secure_hash("#{salt}--#{string}") not found.

any ideas? thanks!

it means salt an undefined method :)

i think haven't got salt field in database users table.

show user table structure (or @ least migration)


Comments

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -