Yes! Sorry David I meant exactly what you wrote and yes my GirlPhoto model has a girl_id. Sorry for the wrong information.
I am also using paperclip 2.3.8 and rails 3.0.6. I can't figure out what is wrong, I checked on google and I found a tutorial which is exactly what I have done (the tutorial => http://sleekd.com/general/adding-multiple-images-to-a-rails-model-with-paperclip/). On 28 Μάϊος, 03:44, David Kahn <[email protected]> wrote: > On Fri, May 27, 2011 at 7:23 PM, Yiannis <[email protected]> wrote: > > I have two models, one model girl and one girl_photos (a file upload > > asset). The only code I have in models which describes the association > > is: > > > For the girl => belongs_to :girl and has_attached_file :photo > > For the model girl_photos => has_many :girl_photos and > > accepts_nested_attributes_for :girl_photos > > First, the above does not make sense... do you mean the following: > > Model Girl > has_many :girl_photos > > Model GirlPhotos > belongs_to :girl > > I am assuming that your GirlPhoto model has a girl_id field, correct? > > Anyhow confirm this as if the above is as you say, the associations look > wrong. > > > > > > > > > > > I've tried to save as a nested attribute the photo, it saves the > > association in the database but it doesn't set the name of the image > > and doesn't upload it. > > > I thought that it might be a problem with paperclip so I created > > another test model with no association, just one image upload (in the > > same model) and it worked fine (it uploaded the images and saved it > > correctly). > > > In the log file I see the following: > > INSERT INTO `girls` (`name`, `surname`, `height`, `weight`, > > `description`, `created_at`, `updated_at`) VALUES ('test', 'test', > > 'test', 'test', 'test', '2011-05-27 18:31:57', '2011-05-27 18:31:57') > > > INSERT INTO `girl_photos` (`created_at`, `updated_at`, > > `photo_file_name`, `photo_content_type`, `photo_file_size`, > > `photo_updated_at`, `girl_id`) VALUES ('2011-05-27 18:31:57', > > '2011-05-27 18:31:57', NULL, NULL, NULL, NULL, 4) > > [paperclip] Saving attachments. > > > For some reason, on the second query, it saves the photo but it > > doesn't captures the name and it doesn't upload it. I don't know what > > else could I try or test. > > > Thank you for your help. > > > -- > > You received this message because you are subscribed to the Google Groups > > "Ruby on Rails: Talk" 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/rubyonrails-talk?hl=en. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" 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/rubyonrails-talk?hl=en.

