On Miércoles, 3 de Marzo de 2010 05:09:24 Swartz escribió: > I have tried Googling as well as searching this group for > information.. > I'm a bit confused. AS wiki states that AS supports polymorphic > associations, but when attempting to add drop-down box for one, I get > errors.
AS supports polymorphic associations for example in constraints (for nested scaffolds). It doesn't support them in forms, they are excluded by default. There is two issues with polymorphic associations: - AS doesn't know from what classes include in select tag - One form element is used to fill two attributes (_type and _id attributes) You can build your own override for the column to shown Organization and Individual records mixed in a select, but value cannot be the id because you won't guess if that id is for an organization or individual. You will have to build a value joining the class name and the id, and in controller fill the association, loading the object in a before_filter or overriding do_create and do_update. > > I have: > > class Award > belongs_to :sponsorship, :polymorphic => :true > end > > class Organization > has_many :awards, :as => :sponsorship > end > > class Individual > has_many :awards, :as => :sponsorship > end > > With list/show actions everything is fine and dandy and I can see the > appropriate polymorphic relationships > > While trying to create a select drop-down box in awards_controller > with: > config.columns[:sponsorship].form_ui = :select > > I get the following error: > ActionView::TemplateError (uninitialized constant Award::Sponsorship) > > I'm not sure if it's something I'm not doing right or what I'm trying > to accomplish not directly supported in AS. > > Thanks in advance! -- Sergio Cambra .:: entreCables S.L. ::. Mariana Pineda 23, 50.018 Zaragoza T) 902 021 404 F) 976 52 98 07 E) [email protected] -- You received this message because you are subscribed to the Google Groups "ActiveScaffold : Ruby on Rails plugin" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/activescaffold?hl=en.
