I have a model, Thing, that has a has_many with ThingPhoto, using Paperclip to manage everything. On the ‘show’ view for Thing, I want to have a file upload, and have it relate to the Thing model.
For some reason, I’m totally glitching on how this should be done. I’ve tried doing this (Haml):
- form_for @thing.thing_photos, :html => {:multipart => true} do |f| = f.file_field :photo = f.submit
… and I get this error:
undefined method `array_path' for #<ActionView::Base:0x24d42b4>
Google is failing me. I’m sure this is super easy, but I just can’t get my brain around it.
Edit: I should have mentioned that if I change the @thing.thing_photos to just @thing, it works fine, in that it displays the form, but of course it’s not associated with the correct model.
try
@thing.thing_photos.newthis should instance a new model of thing_photos. If you’re not using nested routes you’ll have to add the thing_id as a hidden field.