0

I set up the Many to Many a couple days ago and came back to the part where we add seed data to test. I added this:

superman = Hero.find_or_create_by(name: 'Superman')
drmanhattan = Hero.find_or_create_by(name: 'Dr. Manhattan')
Team.find_or_create_by(name: "The Watchmen", hero: drmanhattan)
Team.find_or_create_by(name: "Doomnday Clock", hero: drmanhattan)
drmanhattan.teams.find_or_create_by(name:"Team 1")
drmanhattan.teams.find_or_create_by(name:"Team 2")
drmanhattan.teams.find_or_create_by(name:"Team 3")

here’s the error I get:

Caused by:
SQLite3::SQLException: no such column: heros.name
/Users/ryan/.rvm/gems/ruby-2.6.1/gems/sqlite3-

whats strange is I see

:name - in the schema for heros

t.string :name - in the create_heros.rb file. Since everything seems to be here..I'm not clear on what is happening.

Here is my repo https://github.com/planetlucid/Ruby_On_Rails_Project

Thanks in advance for your help.

  • Does this help? https://stackoverflow.com/questions/17150529/why-am-i-asked-to-run-rake-dbmigrate-rails-env-test – Thang Feb 16 '20 at 04:14
  • Whats the point of a team if can only take one hero? That is not a many to many association. – max Feb 16 '20 at 12:43

0 Answers0