1

私のユーザーモデルでは、アップロード時に画像のサイズを変更したいと考えています。Amazon s3に画像を保存しています。ブロックにafter_assignメソッドを追加しようとするまで、すべてがうまく機能し、画像の表示、アップロード、削除などが行われました。image_accessor

エラーは次のとおりです。

None of the functions registered with Dragonfly::Processor were able to deal with the 
method call thumb

オンラインのチュートリアルに従い、すべてを再確認しました。imagemagickまたはrmagickのエラーだと思いますが、両方を再インストールした後、途方にくれました。私のパス$ which convertは /opt/local/bin/convert です。これは、パスが表示されることを確信しています。

プロセスを機能させる方法に関する提案はありますか? Snow Leopard、Ruby 1.9.3、Rails 3.2.5 で実行しています。


参考のため:

ここに私のユーザーモデルがあります:

class User < ActiveRecord::Base

    image_accessor :avatar do
      storage_path{ |file| "#{self.id}/avatar/#{rand(1000)}.#{file.format}" }
      after_assign{ |a| a.thumb!('300x300#') }
    end

  ...

  attr_accessible :name, :location, :avatar, :retained_avatar,
    # Used by Devise
    :email, :password, :password_confirmation, :remember_me, :confirmed_at

  validates_size_of      :avatar, maximum: 5.megabytes, allow_nil: true
  validates_property :format, of: :avatar, 
    in: [ :jpg, :png, :gif ], case_sensitive: false, allow_nil: true, 
    message: "Only .jpg, .png and .gif file formats are supported."

end

これが私のトンボ初期化子です

require 'dragonfly'

app = Dragonfly[:images]

app.configure_with(:imagemagick)
app.configure_with(:rails)

app.datastore = Dragonfly::DataStorage::S3DataStore.new

app.datastore.configure do |c|
  c.bucket_name = ENV['S3_BUCKET']
  c.access_key_id = ENV['S3_KEY']
  c.secret_access_key = ENV['S3_SECRET']
  c.url_scheme = 'https' 
end

app.define_macro(ActiveRecord::Base, :image_accessor)
4

1 に答える 1

2

ファイルが呼び出され:photoた場合、そのファイルは次のようにafter_assignなりますafter_assign { |a| self.photo = a.thumb('300x300#) }

于 2012-07-19T10:20:42.747 に答える