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

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

新規登録して質問してみよう
ただいま回答率
85.50%
Ruby on Rails 5

Ruby on Rails 5は、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

Q&A

1回答

2107閲覧

google2段階認証を有効にした後、サインアップをすると「Email has already been taken」と出て来る

kkk11

総合スコア23

Ruby on Rails 5

Ruby on Rails 5は、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

0グッド

0クリップ

投稿2018/11/11 04:28

#困っていること
自作アプリにログイン機能を追加している段階でサインアップをしても登録されません。
初めはNet::SMTPAuthenticationErrorというエラーが出て来たのですが、rails サーバーを再起動したら治りました。
しかし次にサインアップのフォームでアドレスとパスワードを設定すると
1 error prohibited this user from being saved:
Email has already been taken
というエラーが出て来てサインアップが出来ずに困っています。

#行ったこと
Qiitaにある@cigalecigalesさんの[Rails] deviseの使い方(rails5版)という投稿を見ながらログイン機能の追加をしています。
そして「アカウント登録確認メールを送る」というテーマを見ながら
config/initializers/devise.rb内で

Devise.setup do |config| (省略)... # mail setting config.mailer_sender = "メールアドレス" end

config/environments/development.rb内で

Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. # In the development environment your application's code is reloaded on # every request. This slows down response time but is perfect for development # since you don't have to restart the web server when you make code changes. config.cache_classes = false # Do not eager load code on boot. config.eager_load = false # Show full error reports. config.consider_all_requests_local = true # Enable/disable caching. By default caching is disabled. # Run rails dev:cache to toggle caching. if Rails.root.join('tmp', 'caching-dev.txt').exist? config.action_controller.perform_caching = true config.cache_store = :memory_store config.public_file_server.headers = { 'Cache-Control' => "public, max-age=#{2.days.to_i}" } else config.action_controller.perform_caching = false config.cache_store = :null_store end # Store uploaded files on the local file system (see config/storage.yml for options) config.active_storage.service = :local # Don't care if the mailer can't send. # config.action_mailer.raise_delivery_errors = false config.action_mailer.perform_caching = false # Print deprecation notices to the Rails logger. config.active_support.deprecation = :log # Raise an error on page load if there are pending migrations. config.active_record.migration_error = :page_load # Highlight code that triggered database queries in logs. config.active_record.verbose_query_logs = true # Debug mode disables concatenation and preprocessing of assets. # This option may cause significant delays in view rendering with a large # number of complex assets. config.assets.debug = true # Suppress logger output for asset requests. config.assets.quiet = true # Raises error for missing translations # config.action_view.raise_on_missing_translations = true # Use an evented file watcher to asynchronously detect changes in source code, # routes, locales, etc. This feature depends on the listen gem. config.file_watcher = ActiveSupport::EventedFileUpdateChecker #default url config.action_mailer.default_url_options = {host: 'localhost', port: 3000} #mailer setting config.action_mailer.raise_delivery_errors = true config.action_mailer.delivery_method = :smtp config.action_mailer.smtp_settings = { :address => "smtp.gmail.com", :domain => 'gmail.com', :port => 587, :user_name => "ここには自分のGメールアドレスを入れています。", :password => "2段階認証で作成した16文字のアプリパスワードを入れています。", :authentication => :plain, :enable_starttls_auto => true } end

#どうなったか
結果としてサインアップのフォームは出来たもののメールアドレスとパスワードを設定しても
1 error prohibited this user from being saved:
Email has already been taken
という文字が出て来てサインアップ出来ません。

#ちなみに
ちなみにまだユーザーテーブルなどユーザーは作っていない状態です。

是非手助けお願いします。

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

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

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

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

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

guest

回答1

0

1つのエラーにより、このユーザーの保存が禁止されました:
メールは、すでに使われています
だそうです。

たぶん重複してるのかもしれませんね。
同じメールアドレス使ってるのか..
それともどこかにメールアドレスを2つ記載してるか..
わかりませんけどそうかもしれませんね

投稿2020/02/16 10:53

HTMLdoc

総合スコア67

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

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

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだベストアンサーが選ばれていません

会員登録して回答してみよう

アカウントをお持ちの方は

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

ただいまの回答率
85.50%

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

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

質問する

関連した質問