Hi there,
I''m a newbie in RoR, and have been struggling with has_many_polymorphs
for a while lately. I''m trying to do something that seems pretty
straightforward, but just can''t find the right way to do it.
I have a model that looks quite like this:
class Attachment < ActiveRecord::Base
belongs_to :attachable, :polymorphic => true
belongs_to :attacher, :polymorphic => true
acts_as_double_polymorphic_join :attachables => [:photos, :videos],
:attachers => [:typologies, :areas]
end
What i want to do is to enable the user to select which attachers will
be attaching any given attachable, while creating or updating it.
I''ve successfully created a couple of select lists, one of them
containing the possible types for the attachers, with an ajax
remote_function call to a specific action in the controller that gathers
all the elements of the passed type and inject the results in the second
select list.
But that method seems quite ugly to me, as I have to hard-code the
attacher types and, most importantly, it only allows for a single parent
for each attachable.
I''m almost sure it should be a more railish way to do this, but just
can''t find any useful documentation.
How do you guys do this? Can anyone help me?
Thanks!
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---