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!
on 2009-06-01 09:15