Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests fail for categories/edit and posts/edit #14

Closed
jhharwood88 opened this issue May 22, 2019 · 2 comments
Closed

Tests fail for categories/edit and posts/edit #14

jhharwood88 opened this issue May 22, 2019 · 2 comments

Comments

@jhharwood88
Copy link

After following the lesson the tests fail similarly to the last lab, generating the errors:

Failures:

  1. 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

  2. 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.

@blackwellsmith
Copy link

this is happening to me

@drakeltheryuujin
Copy link

drakeltheryuujin commented Oct 16, 2019

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. 💙

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants