Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial

Robert Ho
Courses Plus Student 11,383 PointsTreebook (Ruby on Rails) Writing Tests Error
Whats up everyone. I'm following the Treebook / Ruby on Rails video tutorials and I've run into a problem that I can't seem to figure out. I get 4 errors while running my tests but am going just paste one of them since they all seem to come from the same problem:
4) Error:
test_a_user_should_have_a_unique_profile_name(UserTest):
ActiveRecord::StatementInvalid: SQLite3::SQLException: table users has no column named password: INSERT INTO "users" ("first_name", "last_name", "email", "profile_name", "password", "password_confirmation", "created_at", "updated_at", "id") VALUES ('Bobby', 'Ho', 'bobbyho@gmail.com', 'bobbyho', 'password', 'password', '2013-01-31 08:25:56', '2013-01-31 08:25:56', 957904360)
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/sqlite3-1.3.7/lib/sqlite3/database.rb:91:in initialize'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/sqlite3-1.3.7/lib/sqlite3/database.rb:91:in
new'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/sqlite3-1.3.7/lib/sqlite3/database.rb:91:in prepare'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/sqlite3-1.3.7/lib/sqlite3/database.rb:134:in
execute'
The error is way longer than that but I think you guys get the point lol. Any would help would be greatly appreciated! Thanks in advance.
-Bobby
10 Answers

Jason Seifer
Treehouse Guest TeacherHey Will,
The reason mine pass and yours fail is that there's an error in the video (that we've got on the map to fix) where I delete those lines.
The password and password_confirmation fields in the user's fixture errors out because they aren't columns in the database. The fixtures are loaded in to the database and the columns need to be present for it to work. If we wanted to have a password for the user, we would need to use the "encrypted_password" column which devise automatically loads for us based on the user's password and password_confirmation. This is only for test purposes -- the regular site is not affected in development or production mode.

Colin Stodd
3,160 PointsMight be good to include this info in the "Teachers notes".

Jason Seifer
Treehouse Guest TeacherHey Robert, try taking out the password and password_confirmation fields from your test/fixtures/users.yml file.

justinsinichko
2,071 PointsStill an issue in the tutorial that stumped me until I thought to google.

Hardik Dangar
Courses Plus Student 856 PointsDoes users table have a password field? at first look it looks like Activerecord is throwing error cause its not able to found password field.

Robert Ho
Courses Plus Student 11,383 PointsThanks for your replies! Jason, your solution worked.
I'm still a super noob in both Ruby and RoRails, so I'm just diving into these tutorials and not fully understanding everything yet. I do plan to go over these video tutorials again with more studying and research, but I was just wondering why is it that the tests that you created in the videos pass for you but didn't pass for me? I copied everything exactly as you did and did it multiple times with the same code. Thanks so much for your input/help.

Robert Ho
Courses Plus Student 11,383 PointsSorry! To clarify:
Why is it when you type both password and password_confirmation, there are no errors? I Thanks!

Jason Seifer
Treehouse Guest TeacherHaving both of those will pass the validation check. If only one is entered the validation fails. However, they are virtual attributes so it may still error out in some cases.

Will Lam
7,027 PointsJust wanted to bring this up as well.. I'm facing the same error as well and like Robert, after removing the password and password_confirmation field in the users.yml file .. it worked.
However, it still doesn't answer the question.. why did my test fail and why did yours pass the video lecture?
Isn't the point of having the password and password confirmation in the users.yml file to specifically test whether passwords were entered or not?
If we remove them, then, in edge cases for people who try to create profiles, they'd be able to do so without a password, then?

Will Lam
7,027 PointsThanks for the thorough explanation, Jason!