500 Internal Server Error
上記のエラーで困っております。
開発環境
docker
ruby on rails6
gem
devise
現在はログインページを少しいじったぐらいなのですがこのエラーの理由が全くわかりません。
Started GET "/admin_users" for 172.18.0.1 at 2020-04-28 08:39:32 +0000
Processing by AdminUsersController#index as HTML
Rendering admin_users/index.html.erb within layouts/application
AdminUser Load (2.7ms) SELECT admin_users
.* FROM admin_users
↳ app/views/admin_users/index.html.erb:15
Rendered admin_users/index.html.erb within layouts/application (Duration: 12.3ms | Allocations: 1014)
Completed 500 Internal Server Error in 138ms (ActiveRecord: 2.7ms | Allocations: 4076)
admin_users/indexページに飛ぶところで毎回以下のページに行ってしまいます。
We're sorry, but something went wrong.
If you are the application owner check the logs for more information.
index
1 2<p id="notice"><%= notice %></p> 3 4<h1>Admin Users</h1> 5 6<table> 7 <thead> 8 <tr> 9 <th>Index</th> 10 <th>Show</th> 11 <th colspan="3"></th> 12 </tr> 13 </thead> 14 15 <tbody> 16 <% @admin_users.each do |admin_user| %> 17 <tr> 18 <td><%= admin_user.id %></td> 19 <td><%= admin_user.membername %></td> 20 <td><%= link_to 'Show', admin_user_path(admin_user.id) %></td> 21 <td><%= link_to 'Edit', edit_admin_user_path(admin_user) %></td> 22 <td><%= link_to 'Destroy', admin_user_path(admin_user.id), method: :delete, data: { confirm: 'Are you sure?' } %></td> 23 </tr> 24 <% end %> 25 </tbody> 26</table> 27 28<br> 29 30<%= link_to 'New Admin User', new_admin_user_path %> 31
model
1class AdminUser < ApplicationRecord 2 # Include default devise modules. Others available are: 3 # :confirmable, :lockable, :timeoutable, :trackable and :omniauthable 4 devise :database_authenticatable, :registerable, 5 :recoverable, :rememberable, :validatable 6end
controller
1class AdminUsersController < ApplicationController 2 before_action :set_admin_user, only: [:show, :edit, :update, :destroy] 3 4 # GET /admin_users 5 # GET /admin_users.json 6 def index 7 @admin_users = AdminUser.all 8 end 9 10 # GET /admin_users/1 11 # GET /admin_users/1.json 12 def show 13 end 14 15 # GET /admin_users/new 16 def new 17 @admin_user = AdminUser.new 18 end 19 20 # GET /admin_users/1/edit 21 def edit 22 end 23 24 # POST /admin_users 25 # POST /admin_users.json 26 def create 27 @admin_user = AdminUser.new(admin_user_params) 28 29 respond_to do |format| 30 if @admin_user.save 31 format.html { redirect_to @admin_user, notice: 'Admin user was successfully created.' } 32 format.json { render :show, status: :created, location: @admin_user } 33 else 34 format.html { render :new } 35 format.json { render json: @admin_user.errors, status: :unprocessable_entity } 36 end 37 end 38 end 39 40 # PATCH/PUT /admin_users/1 41 # PATCH/PUT /admin_users/1.json 42 def update 43 respond_to do |format| 44 if @admin_user.update(admin_user_params) 45 format.html { redirect_to @admin_user, notice: 'Admin user was successfully updated.' } 46 format.json { render :show, status: :ok, location: @admin_user } 47 else 48 format.html { render :edit } 49 format.json { render json: @admin_user.errors, status: :unprocessable_entity } 50 end 51 end 52 end 53 54 # DELETE /admin_users/1 55 # DELETE /admin_users/1.json 56 def destroy 57 @admin_user.destroy 58 respond_to do |format| 59 format.html { redirect_to admin_users_url, notice: 'Admin user was successfully destroyed.' } 60 format.json { head :no_content } 61 end 62 end 63 64 private 65 # Use callbacks to share common setup or constraints between actions. 66 def set_admin_user 67 @admin_user = AdminUser.find(params[:id]) 68 end 69 70 # Only allow a list of trusted parameters through. 71 def admin_user_params 72 params.require(:admin_user).permit(:index, :show) 73 end 74end 75
routes
1Rails.application.routes.draw do 2 3 resources :admin_users 4 devise_for :admin_users 5 # For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html 6end
解決方法知っている方いたらよろしくお願いいたします。
回答1件
あなたの回答
tips
プレビュー