ruby - Rails - SQLite, table error -
im new in rails , have project school. did :
bundle exec rails g migration addtypetocarte type:belongs_to
but have error when did migration (rake db:migrate)
this class addtypetocarte
class addtypetocarte < activerecord::migration def change add_reference :cartes, :type, index: true, foreign_key: true end end
my error in terminal :
sqlite3::sqlexception: no such table: cartes: alter table "cartes" add "type_id" integer/users/pierresisson/documents/hearthdex/db/migrate/20150515075035_add_type_to_carte.rb:3:in `change' activerecord::statementinvalid: sqlite3::sqlexception: no such table: cartes: alter table "cartes" add "type_id" integer /users/pierresisson/documents/hearthdex/db/migrate/20150515075035_add_type_to_carte.rb:3:in `change' sqlite3::sqlexception: no such table: cartes /users/pierresisson/documents/hearthdex/db/migrate/20150515075035_add_type_to_carte.rb:3:in `change'
i tried add type_id doesnt work. think have no table named "cartes" :/ need please, !
first create model named carte (rails g model carte) run rails generate migration addtypereftocarte type:references.
also in carte model file add belongs_to :type. can read more associations here.
Comments
Post a Comment