Polymorphic associations

If i have the string ‘us_address’ how can I use that to create an
instance for a view?

@us_address = UsAddress.new

Also, does anyone have a URL for how to construct forms for use with
polymorphic associations? Everything I’ve seen up to now only shows the
model relationships. How do you prepare to use this association in a
form? What’s the best way to know what partial to load based on what
model a particular association will use?

I need to use multiple address types, us, eu, etc.

Thanks,


Greg D.
Cyberfusion Consulting
http://cyberfusionconsulting.com/

On Wed, 17 Oct 2007, Greg D. wrote:

If i have the string ‘us_address’ how can I use that to create an instance for a view?

@us_address = UsAddress.new

Some peeps from IRC helped me with this yesterday, so for posterity:

@address_type = ‘us_address’

@address = @address_type.camelize.constantize.new


Greg D.
Cyberfusion Consulting
http://cyberfusionconsulting.com/