0

これは本当に変です。私はDeviseを何百回も使ったことがあり、このエラーは一度も起こりませんでした。ここに私のモデルである:レール4 deviseのエラー:SQLite3 :: SQLException:テーブルのユーザーにパスワードの列がありません

class User < ActiveRecord::Base 
    # Include default devise modules. Others available are: 
    # :confirmable, :lockable, :timeoutable and :omniauthable 
    devise :database_authenticatable, :registerable, 
     :recoverable, :rememberable, :trackable, :validatable 
end 

、ここでは、スキーマです:

create_table "users", force: :cascade do |t| 
    t.string "email",     limit: 255, default: "", null: false 
    t.string "encrypted_password",  limit: 255, default: "", null: false 
    t.string "reset_password_token", limit: 255 
    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",  limit: 255 
    t.string "last_sign_in_ip",  limit: 255 
    t.datetime "created_at",          null: false 
    t.datetime "updated_at",          null: false 
    t.string "first_name",    limit: 255 
    t.string "last_name",    limit: 255 
    t.string "type",     limit: 255 
    t.integer "patient_id" 
    end 

    add_index "users", ["email"], name: "index_users_on_email", unique: true 
    add_index "users", ["patient_id"], name: "index_users_on_patient_id" 
    add_index "users", ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true 

私はレールのコンソールと種類に入る:

u = User.create(email:'[email protected]', password: 'password', password_confirmation: 'password') 

何とか私はこのエラーを取得する:

2.2.0 :001 > u = User.create(email:'[email protected]', password: 'password', password_confirmation: 'password') 
    (0.1ms) begin transaction 
    User Exists (0.2ms) SELECT 1 AS one FROM "users" WHERE "users"."email" = '[email protected]' LIMIT 1 
    SQL (0.1ms) INSERT INTO "users" ("email", "password", "encrypted_password", "created_at", "updated_at") VALUES (?, ?, ?, ?, ?) [["email", "[email protected]"], [nil, nil], ["encrypted_password", "$2a$11$XAjcHN39soOIk6xh9CckmOFc7osxpsHfwCX/ASsLXwsRac/UItIli"], ["created_at", "2016-04-06 16:49:47.400937"], ["updated_at", "2016-04-06 16:49:47.400937"]] 
SQLite3::SQLException: table users has no column named password: INSERT INTO "users" ("email", "password", "encrypted_password", "created_at", "updated_at") VALUES (?, ?, ?, ?, ?) 
    (0.0ms) rollback transaction 
ActiveRecord::StatementInvalid: SQLite3::SQLException: table users has no column named password: INSERT INTO "users" ("email", "password", "encrypted_password", "created_at", "updated_at") VALUES (?, ?, ?, ?, ?) 

どうなりますか?私はdevise_token_auth宝石をインストールしましたが、まだ実装していないので、何ができたのか分かりません。

+0

Deviseは ':validatable'モジュール内で' password'と 'password_confirmation'の仮想属性を設定する必要があります。どのようなDeviseバージョンを使用していますか? –

答えて

1

これは、宝石のバージョン管理の問題となりました。それを交換した後

gem 'rails', '4.2.0' 

::私はそうのようなgemfileでレールを持っていた

gem 'rails' 

bundle updateを実行し、問題が停止しました。

関連する問題