I need my user to upload documents such ad pdf and txt on their profile. And I did that using Carrierwave, so I have a list of documents with titles and urls.
But how can I make other users download those files? Do I have to use a gem or is there something native I don't even know since I am very new to rails?
Thanks
EDIT:
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
And then this in the view I want to download files:
<% @society.documents.each do |doc| %>
<%= link_to "Download it", doc.url %> //url is the column name of the saved url
<% end %>
I don't use Carrierwave but I guess it's similar to Paperclip.
Therefore you should be able to use something like this
link_to 'Download file', user.file.url
This is assuming you have a user instantiated object from a Model with a 'file' carrierwave attribute. Replace this with your attribute name.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With