ActionView::MissingTemplate in Users::Registrations#newのエラーが起こり解決の仕方がわかりません。
railsのエラー作成時、新規登録画面のページに登録しようとしたところこのようなエラーが出ました。エラーの意味がわからず解決の仕方が見いだせない状態です。
railsで勉強し始めたばかりなので、知識不足の部分も多いですが、回答いただけると助かります。
new.html.erb
<h2>Sign up</h2> <%= form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %> <%= render "users/shared/error_messages", resource: resource %> <div class="field"> <%= f.label :name %><br /> <%= f.text_field :name, autofocus: true, autocomplete: "name" %> </div> <div class="field"> <%= f.label :password %> <% if @minimum_password_length %> <em>(<%= @minimum_password_length %> characters minimum)</em> <% end %><br /> <%= f.password_field :password, autocomplete: "new-password" %> </div> <div class="field"> <%= f.label :password_confirmation %><br /> <%= f.password_field :password_confirmation, autocomplete: "new-password" %> </div> <div class="actions"> <%= f.submit "Sign up" %> </div> <% end %> <%= render "users/shared/links" %>
app/views/devise/registrations/new.html.erb
<h2>Sign up</h2> <%= form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %> <%= render "devise/shared/error_messages", resource: resource %> <div class="field"> <%= f.label :name %><br /> <%= f.text_field :name, autofocus: true %> </div> <div class="field"> <%= f.label :email %><br /> <%= f.email_field :email, autofocus: true, autocomplete: "email" %> </div> <div class="field"> <%= f.label :password %> <% if @minimum_password_length %> <em>(<%= @minimum_password_length %> characters minimum)</em> <% end %><br /> <%= f.password_field :password, autocomplete: "new-password" %> </div> <div class="field"> <%= f.label :password_confirmation %><br /> <%= f.password_field :password_confirmation, autocomplete: "new-password" %> </div> <div class="actions"> <%= f.submit "Sign up" %> </div> <% end %> <%= render "devise/shared/links" %>
app/views/devise/sessions/new.html.erb
<h2>Log in</h2> <%= form_for(resource, as: resource_name, url: session_path(resource_name)) do |f| %> <div class="field"> <%= f.label :name %><br /> <%= f.text_field :name, autofocus: true, autocomplete: "name" %> </div> <div class="field"> <%= f.label :password %><br /> <%= f.password_field :password, autocomplete: "current-password" %> </div> <% if devise_mapping.rememberable? %> <div class="field"> <%= f.check_box :remember_me %> <%= f.label :remember_me %> </div> <% end %> <div class="actions"> <%= f.submit "Log in" %> </div> <% end %> <%= render "devise/shared/links" %>
ログイン前
app/views/homes/top.html.erb
<main> <div class="bookers-title"> <h1>welcome to<%= fa_icon("book") %><span>Bookers !!</span></span></h1> <p>in <%= fa_icon("book") %><span>Bookers,</span></p> <p>you can share and exchange your opinions,inpressinons,and emotions</p> <p>about various books!</p> </div> <div class="bookers-link"> <%= link_to '新規登録', new_user_registration_path %><br> <%= link_to 'ログイン', new_user_session_path %> </div> </main>
ログイン後
app/views/homes/mypage.html.erb
<%= current_user.name %><br> <%= current_user.email %><br> <%= link_to 'ログアウト', destroy_user_session_path, method: :delete %>
app/controllers/users/registrations_controller.rb
# frozen_string_literal: true class Users::RegistrationsController < Devise::RegistrationsController before_action :configure_sign_up_params, only: [:create] # before_action :configure_account_update_params, only: [:update] # GET /resource/sign_up # def new # super # end # POST /resource # def create # super # end # GET /resource/edit # def edit # super # end # PUT /resource # def update # super # end # DELETE /resource # def destroy # super # end # GET /resource/cancel # Forces the session data which is usually expired after sign # in to be expired now. This is useful if the user wants to # cancel oauth signing in/up in the middle of the process, # removing all OAuth session data. # def cancel # super # end # protected # If you have extra params to permit, append them to the sanitizer. def configure_sign_up_params devise_parameter_sanitizer.permit(:sign_up, keys: [:name, :email]) end # end # If you have extra params to permit, append them to the sanitizer. # def configure_account_update_params # devise_parameter_sanitizer.permit(:account_update, keys: [:attribute]) # end # The path used after sign up. def after_sign_up_path_for(resource) mypage_path end # The path used after sign up for inactive accounts. # def after_inactive_sign_up_path_for(resource) # super(resource) # end end
app/controllers/users/sessions_controller.rb
# frozen_string_literal: true class Users::SessionsController < Devise::SessionsController # before_action :configure_sign_in_params, only: [:create] # GET /resource/sign_in # def new # super # end # POST /resource/sign_in # def create # super # end # DELETE /resource/sign_out # def destroy # super # end # protected # If you have extra params to permit, append them to the sanitizer. # def configure_sign_in_params # devise_parameter_sanitizer.permit(:sign_in, keys: [:attribute]) # end def after_sign_in_path_for(resource) mypage_path end def after_sign_out_path_for(resource) root_path end end
試したこと
・ログインはできるのですが、ログインした後ログアウトし、新規登録した際エラーが出ます。
・error文の理解はできたのですが、どこをどうすれば良いかわかりません
参考サイト
・ログイン画面を作る際はこのサイトを参考にしました。
https://qiita.com/japwork/items/275110b810965fbdf72f
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。