1

I'm having some problems with signing up in my rails app, with the error coming up of
"column email is not unique"
despite the fact I know that I haven't used this particular email address before. I thought I'd check my database anyway, and ran:

rails console -e=test 

looking at Users.all to see what records were saved. However, not only are none of them saved, but I get the error:

**SQLite3::SQLException: no such table: users: SELECT "users".* FROM "users" ActiveRecord::StatementInvalid: SQLite3::SQLException: no such table: users: SELECT "users".* FROM "users"** 

But in my schema, it clearly says

 create_table "users", force: true do |t| t.string "email", default: "", null: false t.string "encrypted_password", default: "", null: false t.string "reset_password_token" t.datetime "reset_password_sent_at" t.datetime "remember_created_at" t.integer "sign_in_count", default: 0, null: false t.datetime "current_sign_in_at" t.datetime "last_sign_in_at" t.string "current_sign_in_ip" t.string "last_sign_in_ip" t.datetime "created_at" t.datetime "updated_at" t.string "provider" t.string "uid" end 

and nothing happens if I keep trying to db:migrate or db:migrate RAILS_ENV=development.
Any suggestions please?

Edit: running rails console (not -e=test) results in this:

#<ActiveRecord::Relation [#<User id: 1, email: "", encrypted_password: "", reset_password_token: nil, reset_password_sent_at: nil, remember_created_at: nil, sign_in_count: 0, current_sign_in_at: nil, last_sign_in_at: nil, current_sign_in_ip: nil, last_sign_in_ip: nil, created_at: "2014-09-22 14:03:39", updated_at: "2014-09-22 14:03:39", provider: nil, uid: nil>]> 
4
  • 1
    rails console -e=test opening your test console not development console so try rails console and then see database there Commented Sep 26, 2014 at 10:15
  • are you working in the same directory? coz it is a common mistake. Commented Sep 26, 2014 at 10:28
  • 1
    Did you run: RAILS_ENV=test rake db:create db:migrate before running any other command? Commented Sep 26, 2014 at 11:49
  • I did db:migrate RAILS_ENV=development, and also tried without the rails_env bit. Commented Sep 26, 2014 at 12:54

1 Answer 1

2

it looks like you haven't created your database in your test environment. Run:

rake db:create RAILS_ENV=test rake db:migrate RAILS_ENV=test 

that should hopefully solve it

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.