0

这是我在 /app/library/stone.rb 中的模型

class Library::Stone < ActiveRecord::Base
   attr_accessible :group, :healing, :life, :logo, :magic, :name, :other, :place,    :structure, :view

   mount_uploader :logo, LogoUploader

   before_save :cap_group

   def cap_group
     self.name = self.name.mb_chars.capitalize.to_s
     self.group = self.name[0]
   end

end

这是上传器 /app/uploaders/logo_uploader.rb

class LogoUploader < CarrierWave::Uploader::Base
  storage :file

  def store_dir
     "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
  end

  version :thumb do
    process :resize_to_limit => [200, 300]
  end

end

问题是这在控制台中有效,但是当我在浏览器中尝试时,图像没有正确上传。我认为这是因为不知何故

4

1 回答 1

0

尝试查看您的开发日志,并查看它显示的错误。

或者尝试像这样在您的上传器中“模块”RMagick:https ://github.com/lccezinha/rails3-twitter-bootstrap/blob/master/app/uploaders/archive_uploader.rb并在您的 Gemfile 中包含

gem 'carrierwave'
gem 'rmagick'

并运行捆绑命令

bundle install
于 2012-10-31T12:52:48.243 回答