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:in
`compute_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:in
`const_missing''
from (eval):1:in `compute_type''
from
./script/../config/../config/../vendor/rails/activerecord/lib/active_record/reflection.rb:112:in
`klass''
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:in
`source_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:in
`initialize''
from
./script/../config/../config/../vendor/rails/activerecord/lib/active_record/associations.rb:920:in
`effects''
from (irb):5
On Nov 24, 4:02 pm, "dph"
<smarmton...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> 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 aPolymorphicmodel 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
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---