Reputation: 34206
In my user model I want to resize the image on upload. I am storing the images on amazon s3. Everything worked great and the image displays, uploads, deletes, etc. until I tried to add the after_assign
method in the image_accessor
block.
Here is the error:
None of the functions registered with Dragonfly::Processor were able to deal with the
method call thumb
I've followed the tutorials online, and double-checked everything. I figure it is an error with imagemagick or rmagick, but after reinstalling both Im at a loss. My path for $ which convert
is /opt/local/bin/convert which I am pretty sure is good that the path shows up.
Any suggestions on how to get process to work? I am running on Snow Leopard, Ruby 1.9.3 and Rails 3.2.5
For reference:
Here is my user model:
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
Here is my dragonfly initializer
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)
Upvotes: 1
Views: 1170
Reputation: 9691
if your file is called :photo
, then its after_assign
should be after_assign { |a| self.photo = a.thumb('300x300#) }
Upvotes: 2