On Fri, May 27, 2011 at 7:23 PM, Yiannis <istoseli...@gmail.com> 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 rubyonrails-talk@googlegroups.com.
> To unsubscribe from this group, send email to
> rubyonrails-talk+unsubscr...@googlegroups.com.
> 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 rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to