Forum: Ruby on Rails Perplexing nested form issue

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
4956b715c43829ef0b41ad52e606a6a8?d=identicon&s=25 nodoubtarockstar (Guest)
on 2009-06-01 09:15
(Received via mailing list)
Two apps, both running Rails 2.3.2, local machine, development
environment, just to clarify that all gems are the same (obviously)
and most of the code is "standard fare" --- CRUD and such, nothing
fancy going on.

Now that that's out of the way, here's the issue...

In both apps, I have objects which "belong_to" another object, of
which both have accepts_nested_attributes_for said objects.

In both apps, in the form view for each particular object, I want to
do multiple-child-object creation... So in other words, in App 1, I
have loan_applications. loan_application has_many :items -- as such,
an item belongs_to :loan_application

Thus I am able to generate 3 sets of "item fields" in the form so that
a user can essentially create 3 items along with their application.

In App 2, I have products. Similarly, product has_many :photos, :as
=> :owner, and therefore photo belongs_to :owner, :polymorphic =>
true.

So, as you can see the only difference so far is the polymorphism.
However, a photo also has_attachment, since I am using attachment_fu.

I am re-using the code that I wrote for the loan_application items for
the product photos. Fairly straightforward, right? Very similar
assocation (just has_many on both)... but the form output is
completely different. The photos don't output the proper id or name
attributes on the file field. Take a look at the pastie below, you
will see very very few differences between the two (in fact they are
differences I already pointed out, polymorphism and attachment_fu).

http://pastie.org/496243

So my thought is, maybe nested fields_for hasn't come far enough for
polymorphic associations? That just seems quite odd...

Any thoughts/feedback/musings welcome, I'd love to get this figured
out so that I can continue on to bigger-better problem-solving :)

Cheers!
This topic is locked and can not be replied to.