0

I use Paperclip for a model's avatars. In a view of the model I show a list of images, and I would like to be able to change the model's avatar by clicking on one of those images.

The 2nd answer here works well in order to update the avatar, but how can I execute it inside a link?

Community
  • 1
  • 1
amoks
  • 123
  • 9
  • The furthest I've got is this link: `<%= link_to "Update", {:action => :update_avatar, :id => @artist.id, :url => i.url}, :method => :put %>` with this route `put '/artists/:id/update_avatar/:url' => 'artists#update_avatar', :as => 'update_avatar'`. The controller `update_avatar` also exists . The error this is throwing is no mathing routes – amoks Mar 07 '15 at 10:29

1 Answers1

0

I solved it myself. I just updated the route to

put '/artists/:id/update_avatar' => 'artists#update_avatar', :as => 'update_avatar'

and then changed the link to

<%= link_to "Update Avatar", {:action => :update_avatar, :id => @artist.id, :url => i.url}, :method => :put %>
Baldrick
  • 23,882
  • 6
  • 74
  • 79
amoks
  • 123
  • 9