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

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

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

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

Ruby on Rails

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

Q&A

解決済

2回答

2012閲覧

Deviseで新規登録が実装できない

ckr

総合スコア23

Devise

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

Ruby on Rails

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

0グッド

0クリップ

投稿2020/04/05 12:53

現在、Deviseを使ったユーザーの新規登録機能を実装しております。

数日前まで問題なく新規登録機能が設定できておりましたが
先ほど、ユーザーの新規登録を実行しようとしたところ、フォームから登録ボタンを押しても、フラッシュメッセージやページのリダイレクトなどが反応せず、登録ができなくなってしまいました。

下記に関係がありそうなコードを貼らせていただきますので、解決法についておわかりの方がいらっしゃれば
ご教示いただけますでしょうか。

routes.rb

1Rails.application.routes.draw do 2 devise_for :users, 3 controllers: { registrations: 'registrations' } 4 5 root 'pages#home' 6 get 'pages/about' 7 get 'pages/help' 8 get 'pages/terms' 9 10 get '/users/:id', to: 'users#show',as: 'user' 11 delete 'users/:id', to: 'users#destroy',as:'user_destroy' 12 13 14 mount LetterOpenerWeb::Engine, at: "/letter_opener" if Rails.env.development? 15 resources :contacts 16 resources :posts, only: %i(index new create show edit) 17 resources :chat, only: %i(create show) 18 19end 20

registration_controller.rb

1class RegistrationsController < Devise::RegistrationsController 2 def after_sign_up_path_for(resource) 3 root_payh 4 end 5 6 protected 7 8 def update_resource(resource, params) 9 resource.update_without_current_password(params) 10 end 11 12 def after_update_path_for(resource) 13 user_path(resource) 14 end 15 16 end

registration/new.html.erb

1<% provide(:title, "新規登録") %> 2<div class="form-group text-center"> 3 <h2>新規登録</h2> 4 5 <%= form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %> 6 <%= render "devise/shared/error_messages", resource: resource %> 7 8 <div class="field"> 9 <%= f.label :email %><br /> 10 <%= f.email_field :email, autofocus: true, autocomplete: "email" %> 11 </div> 12 13 <div class="field"> 14 <%= f.label :name %><br /> 15 <%= f.text_field :name, autofocus: true, autocomplete: "name" %> 16 </div> 17 18 <div class="field"> 19 <%= f.label :password %> 20 <% if @minimum_password_length %> 21 <em>(<%= @minimum_password_length %> characters minimum)</em> 22 <% end %><br /> 23 <%= f.password_field :password, autocomplete: "new-password" %> 24 </div> 25 26 <div class="field"> 27 <%= f.label :password_confirmation %><br /> 28 <%= f.password_field :password_confirmation, autocomplete: "new-password" %> 29 </div> 30</div> 31 32 33 <div class="terms"> 34 <p>ユーザー利用規約に同意します。</p> 35 <%= link_to "ユーザー利用規約",pages_terms_path %> 36 </div> 37 38 <div class="actions"> 39 <%= f.submit "登録する", class: "btn btn-primary w-100" %> 40 </div> 41 <% end %> 42</div> 43 44 45<%= render "devise/shared/links" %>

application_controller.rb

1class ApplicationController < ActionController::Base 2 protect_from_forgery with: :exception 3 4 before_action :configure_permitted_parameters, if: :devise_controller? 5 protected 6 7 def configure_permitted_parameters 8 added_attrs = [:name,:email,:sex,:profile,:profile_photo,:age,:address] 9 devise_parameter_sanitizer.permit(:sign_up, keys: added_attrs) 10 devise_parameter_sanitizer.permit(:account_update, keys: added_attrs) 11 end 12end 13

config/environment/development.rb

1Rails.application.configure do 2 # Settings specified here will take precedence over those in config/application.rb. 3 4 # In the development environment your application's code is reloaded on 5 # every request. This slows down response time but is perfect for development 6 # since you don't have to restart the web server when you make code changes. 7 config.cache_classes = false 8 9 # Do not eager load code on boot. 10 config.eager_load = false 11 12 # Show full error reports. 13 config.consider_all_requests_local = true 14 15 # Enable/disable caching. By default caching is disabled. 16 # Run rails dev:cache to toggle caching. 17 if Rails.root.join('tmp', 'caching-dev.txt').exist? 18 config.action_controller.perform_caching = true 19 20 config.cache_store = :memory_store 21 config.public_file_server.headers = { 22 'Cache-Control' => "public, max-age=#{2.days.to_i}" 23 } 24 else 25 config.action_controller.perform_caching = false 26 27 config.cache_store = :null_store 28 end 29 30 # Store uploaded files on the local file system (see config/storage.yml for options) 31 config.active_storage.service = :local 32 33 # Don't care if the mailer can't send. 34 config.action_mailer.raise_delivery_errors = false 35 36 config.action_mailer.perform_caching = false 37 config.action_mailer.default_url_options = { host: 'localhost:3000' } 38 config.action_mailer.delivery_method = :letter_opener_web 39 40 # Print deprecation notices to the Rails logger. 41 config.active_support.deprecation = :log 42 43 # Raise an error on page load if there are pending migrations. 44 config.active_record.migration_error = :page_load 45 46 # Highlight code that triggered database queries in logs. 47 config.active_record.verbose_query_logs = true 48 49 # Debug mode disables concatenation and preprocessing of assets. 50 # This option may cause significant delays in view rendering with a large 51 # number of complex assets. 52 config.assets.debug = true 53 54 # Suppress logger output for asset requests. 55 config.assets.quiet = true 56 57 # Raises error for missing translations 58 # config.action_view.raise_on_missing_translations = true 59 60 # Use an evented file watcher to asynchronously detect changes in source code, 61 # routes, locales, etc. This feature depends on the listen gem. 62 config.file_watcher = ActiveSupport::EventedFileUpdateChecker 63 config.action_mailer.default_url_options = { host: 'localhost', port: 3000 } 64end 65

恐れ入りますが、何卒宜しくお願い致します。

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

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

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

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

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

H4L

2020/04/05 13:41

数日前からソースが変わっていないなら、突然動かなくなるということはあまりないかなと思います。 何か心あたりはありませんでしょうか? また、エラーメッセージなどあれば添付していただきたいです。
ckr

2020/04/05 14:26

コメントいただき、感謝申し上げます。 改めて新規登録を行ってみましたところ、今回は正常に登録できました。 rails consoleでもデータが問題なく登録できていることがわかりました、 なぜ突然登録ができなくなったのか原因は不明ですが、取り急ぎご報告させていただきます。 お忙しいところ、ご覧になっていただき、ありがとうございました。
no1knows

2020/04/06 15:33

解決したなら、「原因は不明ですが、解決したよ」と自己解決していただくと幸いです。
ckr

2020/04/07 03:08

大変失礼致しました。こちら、自己解決に変更させて頂ました。
guest

回答2

0

原因は不明ですが、再度新規投稿画面ページから投稿を試したところ、問題なく動作しました。
原因が分かり次第こちらにコメントさせて頂きます。
お騒がせし、申し訳ございませんでした。

投稿2020/04/07 03:06

ckr

総合スコア23

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

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

0

自己解決

原因は不明ですが、再度新規投稿画面ページから投稿を試したところ、問題なく動作しました。
原因が分かり次第こちらにコメントさせて頂きます。
お騒がせし、申し訳ございませんでした。

投稿2020/04/07 03:05

ckr

総合スコア23

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

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

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

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

ただいまの回答率
85.48%

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

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

質問する

関連した質問