undefined method `save' making test fail before testing to the end

后端 未结 3 1712
暗喜
暗喜 2021-01-26 09:28

I am following ruby.railstutorial.org. I have had some troubles, but I solved them. Now, however, I am googling for quite some time, checked the code, I even have an idea why te

相关标签:
3条回答
  • 2021-01-26 09:44

    This line does have problem

    user_with_same_email = @user.email.upcase
    

    user_with_same_email is an object, you need to set the email attr instead of the object itself.

    user_with_same_email.email = @user.email.upcase
    
    0 讨论(0)
  • 2021-01-26 09:58

    It's saying user_with_same_email is a string and doesn't have a save method.

    Guessing, I'd say you need to create a user object with that email, so you can test that your code finds it and throws the validation.

    0 讨论(0)
  • 2021-01-26 10:01

    I was briefly sidetracked by this error in the instruction myself. In general if one encounters any similar issues I recommend going to the help section of the tutorial. If the issue isn't covered there then you could check out the link to the Official Sample Code that links to github. The code for this issue is correct on that repository. Cheers.

    0 讨论(0)
提交回复
热议问题