簡體   English   中英

ActiveRecord :: RecordNotFound:找不到“ id” = all的播放器

[英]ActiveRecord::RecordNotFound: Couldn't find Player with 'id'=all

Player_controller

類PlayersController <ApplicationController

def index
    @players = Player.all
end

def show
    @player = Player.find(params[:id])
end 

def new
end

def create
    @player = Player.new(player_params)
    @player.save
    redirect_to @player
end

private
    def player_params
    params.require(:player).permit(:name, :description)
end

結束

我正在嘗試顯示存儲在播放器模型中的數據,這是我的show.html

show.html

名稱:

描述:

實際的球員姓名和描述不會顯示在表演動作上。 嘗試使用@players = Player.find(:all)在控制台中進行調試時,這是錯誤消息

SELECT  "players".* FROM "players" WHERE "players"."id" = NULL LIMIT 1
ActiveRecord::RecordNotFound: Couldn't find Player with 'id'=all

您在控制台中使用Player.find(:all) 需要一個id,一個id列表或一個id數組 您可能要使用Player.all

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM