我目前正在设置Active_Admin,因此用户可以使用Carrier Wave创建文章并上传图片来说明它(PaperClip存在太多问题)。
一切正常,直到我添加我的文章.rb'在app/admin
我现在无法启动服务器而不会收到以下错误:undefined method
包含'对于ImageUploader:Class(NoMethodError)`,当我删除文件时错误没有出现。
这是我的上传者:
class ImageUploader < CarrierWave::Uploader::Base
# Include RMagick or MiniMagick support:
# include CarrierWave::RMagick
Include CarrierWave::MiniMagick
# Choose what kind of storage to use for this uploader:
storage :file
# storage :fog
# Override the directory where uploaded files will be stored.
# This is a sensible default for uploaders that are meant to be mounted:
def store_dir
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end
# Create different versions of your uploaded files:
version :thumb do
process resize_to_fit: [250, 0]
end
# Add a white list of extensions which are allowed to be uploaded.
# For images you might use something like this:
def extension_whitelist
%w(jpg jpeg gif png)
end
end
这是我的管理文件夹
中的article.rb文件ActiveAdmin.register Article do
form_for @article, :html => { :multipart => true } do |f|
f.inputs "Article" do
f.input :titre
f.input :contenu
f.input :image, :as => :file
end
f.buttons
end
end
这是我的Gemfile
source 'https://rubygems.org'
#base
gem 'rails', '4.2.5.1'
gem 'mysql2', '>= 0.3.13', '< 0.5'
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.1.0'
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 2.0'
gem 'sdoc', '~> 0.4.0', group: :doc
group :development, :test do
gem 'byebug'
end
group :development do
gem 'web-console', '~> 2.0'
end
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
#Gems installed after
#Contacts
gem 'simple_form'
gem 'mail'
#Admin
gem 'nokogiri', '1.6.8.rc3'
gem 'activeadmin', github: 'activeadmin'
gem 'formtastic', '~> 3.1', '>= 3.1.3'
gem 'devise'
gem 'carrierwave', '>= 1.0.0.beta', '< 2.0'
gem 'mini_magick'
gem 'friendly_id', '~> 5.1.0'
控制器没有任何用处,因为它只显示文章。
我认为错误与miniMagick有关,因为这是唯一的&#34; include&#34;在我的整个项目中,但仍然需要调整一些图片...
欢迎任何帮助
答案 0 :(得分:1)
试试这个,
include CarrierWave::RMagick
OR
include CarrierWave::MiniMagick