2016-07-12 49 views
-2

我想通过使用Paperclip将图像保存到分贝,但附加的图像只是没有被保存到分贝。我正在使用Windows。回形针没有保存图像Rails 4

Model类

has_attached_file :image, 
    :path => ":rails_root/public/system/:attachment/:id/:style/:filename", 
    :url => "/system/:attachment/:id/:style/:filename", 
    :default_url => "/images/:style/missing.png" 
validates_attachment_content_type :image, content_type: /\Aimage\/.*\Z/ 

在控制器:图像被添加到允许PARAMS。

html.erb

<%= form_for @product, html: { multipart: true } do |f| %> 
    <p> 
    <%= f.label :image %><br /> 
    <%= f.file_field :image %> 
    </p> 
    <p> 
    <%= f.submit %> 
    </p> 
<% end %> 

迁移已经完成,字段在数据库中,但什么都没有保存。 正在使用Paperclip 5.0.0和Rails 4.2.6

+0

可能重复[在Windows中安装ImageMagick for paperclip gem](http://stackoverflow.com/questions/16655831/install-imagemagick-for-paperclip-gem-in-windows) – Vucko

回答

0

通过不使用回形针和CarrierWave来解决我的问题。