Добрый день! Кто может покажите пример кода Ruby on Rails как download file с базы данных Mongoid с использованием *Paperclip. Мой код Upload file делает а вот Download выдает ошибку:
ActionController::UrlGenerationError in Reports#show
Вот мой контролер метод
Код Ruby
1
2
3
4 def download
send_file params[:file_name]
end
2
3
4 def download
send_file params[:file_name]
end
Вот моя модель
Код Ruby
1
2
3
4
5
6
7
8
9
10
11 Class Report
include Mongoid::Document
include Mongoid::Timestamps
include Mongoid::Paperclip
include Mongoid::Attributes::Dynamic
field :reort_id, type: Integer
field :report_date, type: DateTime
field :report_name, type: String
has_mongoid_attached_file :uploaded_file
validates_attachment_content_type :uploaded_file, :content_type => %w(text/csv application/vnd.ms-excel)
2
3
4
5
6
7
8
9
10
11 Class Report
include Mongoid::Document
include Mongoid::Timestamps
include Mongoid::Paperclip
include Mongoid::Attributes::Dynamic
field :reort_id, type: Integer
field :report_date, type: DateTime
field :report_name, type: String
has_mongoid_attached_file :uploaded_file
validates_attachment_content_type :uploaded_file, :content_type => %w(text/csv application/vnd.ms-excel)
Вот мой линк
Код Ruby
1
<%= link_to "Download", :action => :download, :file_name => @report.uploaded_file, :html => {:multipart => true} %>
Вот мой рут
Код Ruby
1
2 resources :reports do
get 'download'
2 resources :reports do
get 'download'
Кто может подскажите пожалуйста что не так или приведите пример правильного кода!
Большое спасибо за помощь!