嘗試使用回形針創建圖像到我的(物品清單)時,出現錯誤。瀏覽器輸出的錯誤是:1錯誤禁止保存此列表:圖像包含的內容並非他們所報告的內容**作爲說明,image magic已成功安裝在我的計算機上,並且沒有任何問題使用回形針(本地服務器)上傳圖像時出錯
我listing.rb文件
class Listing < ActiveRecord::Base
has_attached_file :image, :styles => { :medium => "200x", :thumb => "100x100>" }, :default_url => "default.jpg"
validates_attachment_content_type :image, :content_type => /\Aimage\/.*\Z/
end
我的Gemfile
gem "paperclip", "~> 4.3"
我listings_controller
def listing_params
params.require(:listing).permit(:name, :description, :price, :image)
end
end
,最後我的形式
<%= form_for @listing, :html => { :multipart => true } do |f| %>
...
...
<div class="form-group">
<%= f.file_field :image, class: "form-control" %>
</div>
<div class="form-group">
<%= f.submit class: "btn btn-primary" %>
</div>
<% end %>
謝謝!我試過這個,當我重新啓動我的服務器的應用程序不會現在運行?我發佈了我的命令行的屏幕截圖 – westman2222
好了解決了這個問題,這裏是我的PATH C:\ RailsInstaller \ Git \ cmd; C:\ RailsInstaller \ Ruby2.1.0 \ bin; C:\ Users \ Art West \ AppData \ Roaming \ npm; C:\ Program Files(x86)\ GnuWin32/bin但仍然得到相同的原始錯誤 – westman2222
重新安裝圖像魔術,並得到它的工作! – westman2222