I have ActiveModel::ForbiddenAttributesError
when I press create in my form.
In my controller:
def create
@topic = Topic.new(topic_params)
if @topic.save
redirect_to topics_path, notice: 'Topic was successfully created.'
else
render action: 'new'
end
end
def topic_params
params.require(:topic).permit(:name, :published, :title)
end
In the view
<%= f.input :title, label: 'Topic Name' , label_html: { class: "col-sm-4" } ,input_html: { class: 'col-sm-2 form-control' }, required: true %>
This is the log: Requested Params are:
{"utf8"=>"✓", "authenticity_token"=>"uB3l+soqgt0qDX8JakSAPeBukp6oifViaHuxDxE9n/I=", "topic"=>{"title"=>"Selling2"}, "commit"=>"Update Page", "action"=>"create", "controller"=>"topics"}
When I edit an already made topic, I don't get any errors just when I try to create a new one.
Thanks
Thanks to Logan.
I have had a filter at the top of my controller filter_resource_access
. I remove that and all are good.
Anyway, not sure why it happens with filter_resource_access
but that is another topic.
Cheers and thank you Logan.