Polymorphic DB Model

Hello!

I’ve been cracking my head on this for a bit, and I’m ready to plead
for help.

I’m trying to create a Polymorphic model for Effects in my RoR card
game. My original idea was to structure it like this:

class Card < ActiveRecord::Base
has_many :effects, :through => :is_effect

class Effect < ActiveRecord::Base
belongs_to :card
belongs_to :is_effect, :polymorphic => true

class AddSubtractEffect < Effect

Am I going about this the wrong way?

Thanks in advance,

dan

A little more information. I’m using edge rails.

I’ve updated a few models to look like so:

class Card < ActiveRecord::Base
has_many :is_effect, :dependent => :destroy
has_many :effects, :through => :is_effect

class Effect < ActiveRecord::Base
belongs_to :card
belongs_to :is_effect, :polymorphic => true

class AddSubtractEffect < Effect

when I try adding an effect to a Card object, this is what I get:

ArgumentError:
./script/…/config/…/config/…/vendor/rails/activerecord/lib/…/…/activesupport/lib/active_support/dependencies.rb:399:in
to_constant_name': Anonymous modules have no name to be referenced by from ./script/../config/../config/../vendor/rails/activerecord/lib/active_record/base.rb:1359:incompute_type’
from
./script/…/config/…/config/…/vendor/rails/activerecord/lib/…/…/activesupport/lib/active_support/dependencies.rb:211:in
qualified_name_for' from ./script/../config/../config/../vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:470:inconst_missing’
from (eval):1:in compute_type' from ./script/../config/../config/../vendor/rails/activerecord/lib/active_record/reflection.rb:112:inklass’
from
./script/…/config/…/config/…/vendor/rails/activerecord/lib/active_record/reflection.rb:163:in
source_reflection' from ./script/../config/../config/../vendor/rails/activerecord/lib/active_record/reflection.rb:163:insource_reflection’
from
./script/…/config/…/config/…/vendor/rails/activerecord/lib/active_record/reflection.rb:172:in
check_validity!' from ./script/../config/../config/../vendor/rails/activerecord/lib/active_record/associations/has_many_through_association.rb:6:ininitialize’
from
./script/…/config/…/config/…/vendor/rails/activerecord/lib/active_record/associations.rb:920:in
`effects’
from (irb):5