You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After following the lesson the tests fail similarly to the last lab, generating the errors:
Failures:
categories/edit shows an update form that submits content, redirects, and shows the updated content
Failure/Error: category.update(params.require(:category))
ActiveModel::ForbiddenAttributesError:
ActiveModel::ForbiddenAttributesError
posts/edit shows an update form that submits content, redirects, and shows the updated content
Failure/Error: post.update(params.require(:post))
ActiveModel::ForbiddenAttributesError:
ActiveModel::ForbiddenAttributesError
These appear to be caused by issues with the category and posts controller.
The category controller will pass the spec tests if .permit! is added after the update call call
Previously:
def update
category = Category.find(params[:id])
category.update(params.require(:category))
redirect_to category_path(category)
end
Passing:
def update
category = Category.find(params[:id])
category.update(params.require(:category).permit!)
redirect_to category_path(category)
end
The same can be done for the posts controler:
Previously:
def update @post = Post.find(params[:id])
@post.update(params.require(:post))
redirect_to post_path(@post)
end
Passing:
def update @post = Post.find(params[:id])
@post.update(params.require(:post).permit!)
redirect_to post_path(@post)
end
Im assuming this was not the intended function given they are not addressed in the lesson and it appears to be a codealong.
The text was updated successfully, but these errors were encountered:
Thank you for spotting this issue and providing feedback.
We have updated the materials and believe your issue to have been resolved.
We apologize for any frustration you might have encountered during this process but thank you for helping us ensure that those who follow in your path will not encounter the same problems that you faced.
If you do not believe that this issue has been addressed, please re-open this issue. 💙
After following the lesson the tests fail similarly to the last lab, generating the errors:
Failures:
categories/edit shows an update form that submits content, redirects, and shows the updated content
Failure/Error: category.update(params.require(:category))
ActiveModel::ForbiddenAttributesError:
ActiveModel::ForbiddenAttributesError
posts/edit shows an update form that submits content, redirects, and shows the updated content
Failure/Error: post.update(params.require(:post))
ActiveModel::ForbiddenAttributesError:
ActiveModel::ForbiddenAttributesError
These appear to be caused by issues with the category and posts controller.
The category controller will pass the spec tests if .permit! is added after the update call call
Previously:
def update
category = Category.find(params[:id])
category.update(params.require(:category))
redirect_to category_path(category)
end
Passing:
def update
category = Category.find(params[:id])
category.update(params.require(:category).permit!)
redirect_to category_path(category)
end
The same can be done for the posts controler:
Previously:
def update
@post = Post.find(params[:id])
@post.update(params.require(:post))
redirect_to post_path(@post)
end
Passing:
def update
@post = Post.find(params[:id])
@post.update(params.require(:post).permit!)
redirect_to post_path(@post)
end
Im assuming this was not the intended function given they are not addressed in the lesson and it appears to be a codealong.
The text was updated successfully, but these errors were encountered: