If there’s anyone frustrated with the News Stand project … Let me make you a new stan:
User.create step, there’s a bit a correction step you need to implement. I’ve reported the bug but until it’s patched here’s a work around:
In the step 9: When your adding all the columns in your db: migrate you need to add a password column:
t.string :password
otherwise the password_digest becomes the password field and then the bcrypt hashing of the password doesn’t work properly…
And most of all when you try the User.create bit in step 13 will give you an unknown attribute error because low and behold you do not have a password column in yo’ table but you do now because you like reading forums and found this very simple work around. Good for you
Stan on.
3 Likes
Also after getting a little further in the exercise I kept on encountering the authenticity token error that I have encountered previously in the other intermediate Ruby course and looking for a work around by reading old posts on here and else where:
When you are setting up the user controller I forget which step it is but certainly by step 24 when you are filling it out with functionality goodness:
skip_before_action :verify_authenticity_token
put that in before any of the user and user redirects and that should clear up the authenticity token error
Though I have seen on StackOverflow and other such sites DO NOT do this in production code because that makes your authenticate less than robust. So learning to get the exercise done : yes
Real Life: NO. 
We should not add a password column to the Users table/model. The purpose of this setup is to not save the password but instead the digest of the password.
I had the same issue on step 9 User.create(...)
in the rails console, that the argument password:
was not recognized. My problem was that I defined a method has_secure_password
in the user model, instead of calling the has_secure_password
class method.
That is,
don’t do this:
class User < ActiveRecord::Base
def has_secure_password
end
end
do this:
class User < ActiveRecord::Base
has_secure_password
end
thanks for the awesome information.
I called the method from the beginning, didn’t define it as a method in User model but the issue is still there
for POST and PUT actions think is safer to use protect_from_forgery instead of skip_before_action :verify_authenticity_token