使用rails 4强参数时出错。未找到参数:在rails4强参数中
ActionController::ParameterMissing at /questions
param not found: question
我有一个Question model
和questions controller
。这些问题表有content column
这是包含在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