Skip to content

How to: Detect a new file in a mounted uploader

clyfe edited this page May 31, 2011 · 1 revision

In some situations, it might be necessary to execute code when a new file has been assigned to a mounted uploader, before saving the model.

class User < ActiveRecord::Base
  mount_uploader :avatar, AvatarUploader

  def avatar=(obj)
    super(obj)
    # Put your callbacks here, e.g.
    self.moderated = false  
  end
end
Clone this wiki locally