出于安全原因,我决定采用不同的方法进行批量分配,并想知道这是否是在控制器内部进行的安全方法?
QuestionsController
def new
@survey = Survey.find(params[:survey_id])
@question = Question.new
end
def create
@survey = Survey.find(params[:survey_id])
@question = @survey.questions.new
@question.title = params[:question][:title]
@question.description = params[:question][:description]
if @question.save
redirect_to new_survey_question_path
else
render :new
end
end
他们可以更改survey_id
或任何其他列question
吗?除了使用之外,他们是更好的方法attr_accessible
吗?