Mongoid ::回形针图像上传不起作用

时间:2019-02-03 01:30:10

标签: ruby-on-rails mongodb paperclip

我按照这些说明设置了Mongoid :: Paperclip:

https://github.com/mrrooijen/mongoid-paperclip

当我尝试在表单上上传图像时,我没有收到任何错误,但是在显示页面上,我仅获得以下网址:/coverimages/original/missing.png 而不是图像。

class Book
  include Mongoid::Document
  include Mongoid::Paperclip

  field :title, type: String
  field :author, type: String
  field :owned, type: Mongoid::Boolean

  has_mongoid_attached_file :coverImage

end




 def new
    @book = Book.new
  end


  def create
    @book = Book.new(book_params)
respond_to do |format|
  if @book.save
    format.html { redirect_to @book, notice: 'Book was successfully created.' }
    format.json { render :show, status: :created, location: @book }
  else
    format.html { render :new }
    format.json { render json: @book.errors, status: :unprocessable_entity }
  end
    end
  end


  <div class="field">
    <%= form.label :coverImage %>
    <%= form.file_field :coverImage %>
  </div>

0 个答案:

没有答案