user.rb
class User < ActiveRecord::Base
#attr_accessible :name, :email, :password, :password_confirmation
#attr_acessor :password
has_secure_password
before_save { self.email = email.downcase }
email_regex = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i
validates :nickname, :presence => true,
:length => { :maximum => 50 }
validates :email, :presence => true,
:uniqueness => { :case_sensitive => false },
:format => { :with => email_regex }
validates :password, :presence => true,
end
users_controller.rb
class UsersController < ApplicationController
def new
@title = "Sign Up"
@user = User.new
end
def show
@user = User.find(params[:id])
end
def create
@user = User.new(user_params)
if @user.save
redirect_to @user
else
render "new"
end
end
private
def user_params
params.require(:user).permit(:nickname, :email, :password, :password_confirmation )
end
end
答案 0 :(得分:2)
根据评论,即i forgot the comma at the end validates :password, :presence => true,
OP解决了这个问题。我只是将其作为答案发布(不要期望相同的信用)所以SO社区知道问题已经完成并得到了解答。
validates :password, :presence => true,
末尾有一个额外的逗号,导致错误。
删除它可以解决您的问题。
validates :password, :presence => true