Controller not accepting params value but the same value hard coded is accepted
- by Numbers
Rails.logger.info(params[:question])
=> {"title"=>"katt"}
@question_list.questions.create(params[:question])
=> ActiveModel::ForbiddenAttributesError (ActiveModel::ForbiddenAttributesError)
@question_list.questions.create("title"=>"katt")
# SUCCES!
I cannot understand why Rails not accepts the params when the exact same value written by hand works fine?
Update
controller:
def new_question
@question_list.questions.create(params[:question])
render nothing: true
end
private
def set_question_list
@question_list = QuestionList.find(params[:id])
end
def question_list_params
params.require(:question_list).permit(questions_attributes: [:id, :question_list_id, :title, :position, :_destroy])
end
view:
<%= form_for @question_list, url: new_question_question_list_path, remote: true do |f| %>
<%= f.text_field :title %>
<%= f.submit %>
<% end %>