When using strong_params and getting an ActiveModel::ForbiddenAttributesError exception, how do I know which attribute is prohibited? I just switched from attr_accessible , and the debug message was usually pretty good, but not when switching to strong options.
I get this error:
ActiveModel::ForbiddenAttributesError in SnippetsController
This is a nested model.
def snip_params params.require(:snippet).permit(:content, :approved, :user_id, :book_id) end
In parent I used
has_nested_attributes :snippets
Create
def create @snippet = @book.snippets.create(snip_params) @snippet.user = current_user if @snippet.save redirect_to @book flash[:success] = "Snippet submitted and awaiting approval." else flash[:base] = "Someone else has submitted a snippet, please try again later" redirect_to @book end end
Params Content:
{"utf8"=>"β", "authenticity_token"=>"bTRSwFRIhN3l3DkkWPtLzpoQHYD+CezmJQLw8Oz5+3g=", "snippet"=>{"content"=>"<p>AAAAAAAAAAAAA</p>\r\n"}, "commit"=>"Create Snippet", "book_id"=>"1"}
source share