Maher Manoubi Maher Manoubi - 1 year ago 132
Ruby Question

Rails 4.1 Devise 3.3 column users.password does not exist

I want to create a user manually through the console as such:

User.find_or_create_by(email: "", first_name: "Stan", last_name: "Smith", password: "password", password_confirmation: "password", confirmed_at:

I have done this many times in past projects but this time it's not working. It is not picking up the Devise password model attribute so this is the error I get:

PG::UndefinedColumn: ERROR: column users.password does not exist

I have Rails 4.1.4 and Devise 3.3.0. Did something change in the latest versions?


Answer Source

Instead of User.find_or_create_by you should be using User.create.

Devise accepts a password and password confirmation on creation but the actual table only has a column called encrypted_password.

The "find" portion of User.find_or_create_by is looking for a column called "password" which doesn't exist.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download