質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
Devise

Deviseとは、Ruby-on-Railsの認証機能を追加するプラグインです。

Ruby on Rails 4

Ruby on Rails4はRubyによって書かれたオープンソースのウェブフレームワークです。 Ruby on Railsは「設定より規約」の原則に従っており、効率的に作業を行うために再開発を行う必要をなくしてくれます。

Q&A

解決済

1回答

3406閲覧

gemのdeviseについてのです!

Junjun

総合スコア14

Devise

Deviseとは、Ruby-on-Railsの認証機能を追加するプラグインです。

Ruby on Rails 4

Ruby on Rails4はRubyによって書かれたオープンソースのウェブフレームワークです。 Ruby on Railsは「設定より規約」の原則に従っており、効率的に作業を行うために再開発を行う必要をなくしてくれます。

0グッド

1クリップ

投稿2015/09/04 05:13

railsのgemのdeviseを利用しているのですが、sign_upをしようとすると、「undefined local variable or method `unconfirmed_email'」というエラーが発生してしまします。

user.rbに:confirmableを追加した結果、このようなエラーが発生するようになりました。

どのようにすればいいのでしょうか?
回答よろしくお願いします!!!!

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

ベストアンサー

db/migrate 以下にマイグレーションファイルがあるはずなので、「confirmable」に関係する部分のコメントアウトをはずしてください。

Ruby

1class DeviseCreateUsers < ActiveRecord::Migration 2 def change 3 create_table(:users) do |t| 4 ## Database authenticatable 5 t.string :email, null: false, default: "" 6 t.string :encrypted_password, null: false, default: "" 7 8 ## Recoverable 9 t.string :reset_password_token 10 t.datetime :reset_password_sent_at 11 12 ## Rememberable 13 t.datetime :remember_created_at 14 15 ## Trackable 16 t.integer :sign_in_count, default: 0, null: false 17 t.datetime :current_sign_in_at 18 t.datetime :last_sign_in_at 19 t.string :current_sign_in_ip 20 t.string :last_sign_in_ip 21 22 ## Confirmable 23 # t.string :confirmation_token 24 # t.datetime :confirmed_at 25 # t.datetime :confirmation_sent_at 26 # t.string :unconfirmed_email # Only if using reconfirmable 27 28 ## Lockable 29 # t.integer :failed_attempts, default: 0, null: false # Only if lock strategy is :failed_attempts 30 # t.string :unlock_token # Only if unlock strategy is :email or :both 31 # t.datetime :locked_at 32 33 34 t.timestamps 35 end 36 37 add_index :users, :email, unique: true 38 add_index :users, :reset_password_token, unique: true 39 # add_index :users, :confirmation_token, unique: true 40 # add_index :users, :unlock_token, unique: true 41 end 42end

確かこの辺のコメントアウトを外します。

Ruby

1## Confirmable 2# t.string :confirmation_token 3# t.datetime :confirmed_at 4# t.datetime :confirmation_sent_at 5# t.string :unconfirmed_email # Only if using reconfirmable 6 7# add_index :users, :confirmation_token, unique: true

その後rake db:migrateして、サーバー再起動でいけませんか?

投稿2015/09/04 05:51

totom

総合スコア17

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

Junjun

2015/09/04 06:19

参考になりました!ありがとうございます!!!
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問