When assigning attributes, you must pass a hash as an argument

などのエラーの時:edit, update 関数を分ける。


def edit
@question = Question.find(params[:question_id])
@answer = @question.answers.find(params[:id])
end

def update
@question = Question.find(params[:question_id])
@answer = @question.answers.find(params[:id])
if @answer.update_attributes(answer_params)
redirect_to question_path(@question)
else
raise
render 'edit'
end
end