下载上传的文件回形针



我在使用回形针时遇到问题。我可以看到上传的文件,但现在我想有一个下载链接来下载"pdf文件",当点击它时。

我看到这个例子:

<%= link_to "Download", model.whatever.url(:original, false) %>

但是我不知道如何用我自己的观点和模型来实现这一点。

希望有人能帮助我。

编辑:

这是我的模型:

class Contractgegeven < ActiveRecord::Base
  has_attached_file :pdf
    attr_accessible :bedrijfsonderdeel, :bestemd_voor, :betalingsgegevens, :betreft, :contractbeheerder, :contractduur, :einddatum, :ingangsdatum, :opzegtermijn, :soort_contract, :pdf
    end

假设你的模型是Image的,你有:

class Image < ActiveRecord::Base
  has_attached_file :picture

然后你应该写:

Image.last.picture.url(:original, false)

Image.last.url(:original, false)

最新更新