Hello,
I am currently following the Rails Tutorial (Michael Hartl, 14th Chapter) and encountered an issue with the sample data setup.
The tutorial instructs readers to run the usual commands to reset and seed the database:
$ rails db:migrate:reset
$ rails db:seed
However, the db/seeds.rb file includes code that calls a follow method on the User model:
users = User.all
user = users.first
following = users[2..50]
followers = users[3..40]
following.each { |followed| user.follow(followed) }
followers.each { |follower| follower.follow(user) }
At this point in the tutorial, the follow method is not defined in the User model. There is no explanation in the text about how or where to implement this method, yet the seed instructions require it to run successfully. As a result, running rails db:seed produces a NoMethodError.
This is confusing for learners following the tutorial strictly and prevents them from completing the setup. The tutorial’s instructions and the code in seeds.rb are inconsistent, which could cause unnecessary frustration.
I suggest clarifying the tutorial by either:
- Adding a note that the
follow method must be implemented in the User model before running db:seed, or
- Providing the implementation in the tutorial text at the appropriate point.
Thank you for considering this feedback.
Hello,
I am currently following the Rails Tutorial (Michael Hartl, 14th Chapter) and encountered an issue with the sample data setup.
The tutorial instructs readers to run the usual commands to reset and seed the database:
$ rails db:migrate:reset
$ rails db:seed
However, the
db/seeds.rbfile includes code that calls afollowmethod on the User model:users = User.all
user = users.first
following = users[2..50]
followers = users[3..40]
following.each { |followed| user.follow(followed) }
followers.each { |follower| follower.follow(user) }
At this point in the tutorial, the
followmethod is not defined in the User model. There is no explanation in the text about how or where to implement this method, yet the seed instructions require it to run successfully. As a result, runningrails db:seedproduces aNoMethodError.This is confusing for learners following the tutorial strictly and prevents them from completing the setup. The tutorial’s instructions and the code in
seeds.rbare inconsistent, which could cause unnecessary frustration.I suggest clarifying the tutorial by either:
followmethod must be implemented in the User model before runningdb:seed, orThank you for considering this feedback.