Reputation: 3
ever since i updated to rails 4 i've been struggeling with strong_params. I finaly tought i had it but now there seems to an unexpected_end some where. i think i overlook everything but it still seems to be wrong somewhere. i'm very new to ruby on rails aswel.
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
Upvotes: 0
Views: 473
Reputation: 53018
As per the comment, i.e., i forgot the comma at the end validates :password, :presence => true,
OP has resolved the issue. I am just posting it as an answer (not expecting credit for the same) so SO community knows that the question is complete and answered.
You have an extra comma at the end of validates :password, :presence => true,
which is causing the error.
Removing that would resolve your issue.
validates :password, :presence => true
Upvotes: 2