Hi

I'm trying to delete a user's profile image that was uploaded with
attachment_fu directly to storage, without going to the view of the
Photo controller.

Basically the model is set up so

user has many photos
photos belong to user

    @user = User.find(params[:id])
    @photo = Photo.new(params[:photo])

there is no problem viewing the photos but i'm trying to have a link
next to the picture in the view of the User controller which would
delete the photo.

i tried:

def destroyphoto
    @user = User.find(params[:id])
    @photo = @user.photos.find(params[:id])
    @photo.destroy
end

with:

<%= link_to "delete", destroyphoto_user_url, :method => :delete %>

but i get the:

Couldn't find Photo with ID=1 AND (`photos`.user_id = 1)

the photo's id isn't 1 and it's actually many because of the original
image and the thumbnails.

any ideas?
-- 
Posted via http://www.ruby-forum.com/.

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to