inheritance - Rails "superclass mismatch for class (TypeError)". A well documented error, but I need some tailored advice -
ok. understand why i'm getting error. according stackoverflow question, "that error shows when redeclare class that’s been declared". question seems point out solutions, not quite. have additional questions.
here's have...
/models/item.rb
class item < activerecord::base .. end class theme < item end class setting < item end
this item model has existed quite time. added sing inheritance theme , setting.
as as...
/models/setting.rb
class setting < activerecord::base .. end
/models/theme.rb
class theme < activerecord::base .. end
so makes sense why i'm getting error. never got error in local workspace, when pushed heroku, did migrations, , tried run "heroku run rails c". run command, error , booted out.
according answers, should quit console , come in. however, can't in begin with. launch "heroku run rails c", booted.
additionally, if wipe db, , remigrate everything, going same error given order of operations of these table creates, etc? don't want have hack solution fix everytime. if run migrations, ideally working straight away.
what do solve issue?
you're trying redefine theme
, setting
model. in app/models/item.rb
define them inherited item
class , in app/models/theme.rb
, app/models/setting.rb
define them inherit activerecord::base
directly.
you can see error in heroku (probably production) environment because in dev env eager loding option turned off default , therefore rails not load in classess when boots.
is item
model using single table inheritance (sti)? because case when need inherit theme
, settings
model item
model.
if move theme
, setting
class definitions app/models/theme.rb
, app/models/setting.rb
files accordingly , remove definitions there.
if not, remove theme
, setting
class definitions app/models/item.rb
file , you'll go.
Comments
Post a Comment