【问题标题】:Updating a model's avatar through a link通过链接更新模型的头像
【发布时间】:2015-05-08 17:49:21
【问题描述】:

我使用 Paperclip 作为模特的头像。在模型视图中,我显示了一个图像列表,我希望能够通过单击其中一个图像来更改模型的头像。

2nd answer here 可以很好地更新头像,但如何在链接中执行它?

【问题讨论】:

  • 我得到的最远的是这个链接:<%= link_to "Update", {:action => :update_avatar, :id => @artist.id, :url => i.url}, :method => :put %> 这条路线put '/artists/:id/update_avatar/:url' => 'artists#update_avatar', :as => 'update_avatar'。控制器update_avatar 也存在。这是抛出的错误是没有数学路线

标签: ruby-on-rails paperclip


【解决方案1】:

我自己解决了。我刚刚更新了到

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

然后把链接改成

<%= link_to "Update Avatar", {:action => :update_avatar, :id => @artist.id, :url => i.url}, :method => :put %>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-08-23
    • 2011-05-05
    • 1970-01-01
    相关资源
    最近更新 更多