NoMethodError when I try to acces a field of an object taken from the DB

前端 未结 4 1728
[愿得一人]
[愿得一人] 2021-01-25 20:19

  Let\'s say that I have a model called Tweet with the following fields

  • 1. id
  • 2. content
  • 3. created_at
  • 4. user_id
  • <
4条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-01-25 20:54

    Do this instead, you need to add first

    @tweet = Tweet.where(id: 64).first
    

提交回复
热议问题