Why use ‘reload’ method after saving object? (Hartl Rails Tut 6.30)

Yes in this case @user.reload.email and @user.email is the same thing. But it’s good practice to use @user.reload.email instead of @user.email to check what is exactly saved in the database i mean you don’t know if you or someone add some code in after_save which changes it’s value then it will not have effect on your tests.

EDIT:
And also what you are checking is what’s saved in the database so @user.reload.email exactly reflects what’s saved in database then @user.email

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)