강력한 매개 변수를 콘솔에 넣으려고하면 서버가 응답하지 않고 오류가 발생하지 않습니다. 아무것도. 그리고 create 액션은 작동하지 않습니다. 어떤 생각? 제출하려는 양식에 누에 고치를 사용하고 있습니다. 당신이 실제 레일 콘솔을 의미하는 경우동작 만들기 - 레일
감사합니다,
def new
@game = Game.new
@level = @game.levels.build
end
def create
@game = Game.new(game_params)
puts @game
if @game.save
redirect_to @game, notice: 'Game was successfully created.'
else
render :new
end
end
private
def game_params
params.require(:game).permit(:name, :publisher, :year, :description, :image, levels_attributes: [:id, :name, :sort_order, :_destroy])
end
내 게임 클래스는
class Game < ActiveRecord::Base
has_many :levels
accepts_nested_attributes_for :levels, :reject_if => :all_blank, :allow_destroy => true
mount_uploader :image, ImageUploader
end
요청에 의해'create' 액션이 실행 되었습니까? 메소드의 처음에'puts 'Hi''를 추가하면 어떨까요? 그 결과는 콘솔에 출력됩니까? –
@ChrisPeters가 물었던 것 외에도 Game 클래스를 게시 할 수 있습니까? – MCBama
@ChrisPeters 여러분, 고마워요. 나는 이상한 것을 알아 차린다. 처음으로 양식을로드 할 때, 콘솔에 "안녕"을 넣더라도 제출이 작동하지 않습니다. 그러나 페이지를 새로 고침하면 양식이 문제없이 작동합니다. 그러나 재 장전 후에 만. – rovitulli