Active Admin solution for ForbiddenAttributes
While working on a Project, Tasks application with active admin, I was not able to create a project or task and got this error:
ActiveModel::ForbiddenAttributesError in Admin::TasksController#create
Solution...
Add following code to admin/task.rb
controller do
def permitted_params
params.permit task: [:title, :project_id, :admin_user_id, :is_done, :due_date]
end
end
and Add following code to admin/product.rb
controller do
def permitted_params
params.permit project: [:title]
end
end
DONE :)
Written by Ahmed Nadar
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Ruby
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#