레일 4 개의 강력한 매개 변수를 사용하는 동안 오류가 발생했습니다.param을 (를) 찾을 수 없습니다. rails4 강력한 매개 변수에서
ActionController::ParameterMissing at /questions
param not found: question
나는 Question model
과 questions controller
있습니다.
def index
@question = Question.new(question_params)
@questioner = Questioner.new(questioner_params)
end
첫째, 더 questioner_params
없다 : 질문 표는이 문제는 컨트롤러의 index 액션에 questions controller
class QuestionsController < ApplicationController
def index
@question = Question.new(question_params)
@questioner = Questioner.new(questioner_params)
end
def new
@question = Question.new(question_params)
end
def edit
@question = find(params[:id])
raise "Question Not edited!" unless @question
end
def create
@question = Question.new(question_params)
respond_to do |wants|
if @question.save
flash[:notice] = 'You have successfully posted the questions!'
wants.html { redirect_to(root_path) }
wants.xml { render :xml => @question, :status => :created, :location => @question }
else
flash[:error] = "Please review the problems below."
wants.html { redirect_to(questions_path) }
wants.xml { render :xml => @question.errors, :status => :unprocessable_entity }
end
end
end
private
def question_params
params.require(:question).permit(:content)
end
end
색인 페이지에 2 개의 양식이 있습니다. 하나는 질문과 다른 질문자를 사용합니다 – ben