On Oct 9, 3:22 am, Jonny Dalgleish <[email protected]> wrote:
> Hi All,
>
> I thought Id try out this group…
>
> Here's where I'm at:
>
> Tour
> has_many :photos
>
> Photo
> belongs_to :tour
>
Sounds like you should look at accepts_nested_attributes_for - it's
designed to make it easy to edit/create related objects within a
single form.
Fred
> --
>
> Here is my edit view… (Im using HAML)
>
> = semantic_form_for @tour , :html => {:multipart => true} do |f|
> = f.inputs
>
> #photos
> - unless @tour.new_record?
> = semantic_fields_for Photo.new do |f|
> = f.file_field :image, :rel => tour_photos_path(@tour)
>
> = render :partial => 'photos/photo', :collection => @tour.photos
>
> = f.buttons
>
> Here is the partial that is rendered when an image is uploaded:
>
> .photo[photo]
> .uploaded
> = image_tag photo.image_url(:small_thumb) if photo.image?
> = button_link_to "Delete", tour_photo_path(@tour, photo), :method =>
> :delete, :confirm => "Are you sure?", :remote => :true
>
> ---
>
> Some how I need to get something like this into the returned partial:
>
> = semantic_form_for @tour.photo do |f|
> = f.text_field :description
>
> I need to be able to edit a field on the uploaded images (once they have
> uploaded)… (the description field)…
>
> But I can't figure it out…
>
> Anyone have any clues where Im going wrong?
>
> Thanks for your help,
>
> Jonny
--
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.