Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Adam Sackfield
Courses Plus Student 19,663 PointsBuild a simple rails application > profile_name uniqueness
Hi, i'm stuck on this video everything was going along with the video until i add the line uniqueness: true to the end of the line validates :profile_name, presence: true in the file user.rb
I have checked over my code several times and seen all the forums on here related to this issue but can't find a solution anywhere. Code and errors are below:
user.rb class User < ActiveRecord::Base # Include default devise modules. Others available are: # :confirmable, :lockable, :timeoutable and :omniauthable devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable
# Setup accessible (or protected) attributes for your model
attr_accessible :email, :password, :password_confirmation, :remember_me,
:first_name, :last_name, :profile_name
# attr_accessible :title, :body
validates :first_name, presence: true
validates :last_name, presence: true
validates :profile_name, presence: true, uniqueness: true
has_many :statuses
def full_name
first_name + " " + last_name
end
end
users.yml ellis: first_name: "Ellis" last_name: "Fisher" email: "ellissbsp@gmail.com" profile_name: "ellisfisher" password: "password" password_confirmation: "password"
user_test.rb require 'test_helper'
class UserTest < ActiveSupport::TestCase
test "a user should enter a first name" do
user = User.new
assert !user.save
assert !user.errors[:first_name].empty?
end
test "a user should enter a last name" do
user = User.new
assert !user.save
assert !user.errors[:last_name].empty?
end
test "a user should enter a profile name" do
user = User.new
assert !user.save
assert !user.errors[:profile_name].empty?
end
test "a user should have a unique profile name" do
user = User.new
user.profile_name = 'ellisfisher'
user.email = "ellissbsp@gmail.com"
user.first_name = "Ellis"
user.last_name = "Fisher"
user.password = "password"
user.password_confirmation = "password"
assert !user.save
assert !user.errors[:profile_name].empty?
end
end
errors below: test_a_user_should_enter_a_first_name(UserTest): ActiveRecord::StatementInvalid:SQLite3::SQLException: table users has no column named "password_confirmation"
that is error 1 of 4 but they all go along the same line. Was unable to copy from console in Cloud9
Hope there is enough information.
Thanks in advance
1 Answer

Adam Sackfield
Pro Student 19,663 PointsSorted it appears it was a devise version issue i think as i changed the password fields to encrypted_password and it works. Is this correct Jason Seifer
There appears to be an error in the video at around the 2 minute mark you run a test and it passes. But prior to that in the users.yml file you had the fields password and password_confirmation but after test ran you did not i assume you stopped recording. But this was not made clear at all and caused me a few hours delay in spotting this.
Adam Sackfield
Pro Student 19,663 PointsAdam Sackfield
Courses Plus Student 19,663 PointsTried the markdown but some of the code just won't set right.