【发布时间】:2015-04-30 09:48:42
【问题描述】:
我需要允许我的用户将 Word 文档(.doc 文件)上传到我的应用程序。图像和 PDF 工作正常,但是当我尝试上传文档时,我得到:
undefined method `documents_path'
这是我的 Document.rb 文件中的代码。
validates :title, presence: true
validates :file,
attachment_content_type: { content_type: ["image/jpg", "image/jpeg", "image/png", "image/gif", "application/pdf", 'application/msword','applicationvnd.ms-word','applicaiton/vnd.openxmlformats-officedocument.wordprocessingm1.document', 'text/plain']},
attachment_size: { less_than: 5.megabytes }
has_attached_file :file, styles: {
thumb: '100x100>',
square: '200x200#',
medium: '350x350>',
pdf_preview: '600x600>'}, processors: [:thumbnail]
这是我的看法:
<%= simple_form_for(@document, multipart: true) do |f| %>
<%= f.input :title, :label => "Name of Document" %>
<%= f.input :hotel_id %>
<%= f.file_field :file, :label => "Upload Document" %>
<%= f.submit 'Submit', :class => "btn btn-primary" %>
<% end %>
还有我的路线:
resources :hotels do
resources :advertisers
resources :documents
end
【问题讨论】:
-
显示您的视图和路线.rb
-
@Yule 为我的问题添加了视图和路线。