我需要我的用戶上傳他們的個人資料上的文檔,如廣告pdf和txt。我使用Carrierwave做到了這一點,所以我有一份包含標題和網址的文檔列表。Rails:如何下載以前上傳的文檔?
但我怎樣才能讓其他用戶下載這些文件?我是否必須使用寶石,或者是否有本地的我不知道,因爲我是非常新的軌道?
感謝
編輯:
society.rb
class Society < ActiveRecord::Base
...
has_many :documents, :dependent => :destroy
end
document.rb
class Document < ActiveRecord::Base
belongs_to :society
mount_uploader :url, DocumentUploader
end
然後在此我要下載文件的視圖:
<% @society.documents.each do |doc| %>
<%= link_to "Download it", doc.url %> //url is the column name of the saved url
<% end %>
也許愚蠢的問題:如何處理您提到的網址給其他用戶? – Romain 2012-07-27 14:54:37
對不起,我不明白你的意思=) – Barbared 2012-07-27 15:01:43
請參閱@ anthonyalberto的回答。 – Romain 2012-07-27 15:04:00