You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I get
2.3.4 :001 > a = Article.first
Article Load (0.2ms) SELECT "articles".* FROM "articles" ORDER BY "articles"."id" ASC LIMIT ? [["LIMIT", 1]]
=> nil
2.3.4 :002 > a.comments
NoMethodError: undefined method `comments' for nil:NilClass
from (irb):2
I don't know if this has to do with models generated being different from the ones shown in the site but I tried both ways and keep getting the same problem.
The text was updated successfully, but these errors were encountered:
a=Article.first# this returned 'nil', there was no article returned from the databasea.comments# this throws an error because there's no "comments" method (or database association) # on the 'nil' that was returned and stored in your 'a' variable.
I get
2.3.4 :001 > a = Article.first
Article Load (0.2ms) SELECT "articles".* FROM "articles" ORDER BY "articles"."id" ASC LIMIT ? [["LIMIT", 1]]
=> nil
2.3.4 :002 > a.comments
NoMethodError: undefined method `comments' for nil:NilClass
from (irb):2
I don't know if this has to do with models generated being different from the ones shown in the site but I tried both ways and keep getting the same problem.
The text was updated successfully, but these errors were encountered: