Skip to content

Instantly share code, notes, and snippets.

@phlegx
Created November 24, 2012 22:56
Show Gist options
  • Save phlegx/4141727 to your computer and use it in GitHub Desktop.
Save phlegx/4141727 to your computer and use it in GitHub Desktop.
class Upload < ActiveRecord::Base
attr_accessible :upload
has_attached_file :upload, :processors => [:watermark]
before_save :test
#https://gist.github.com/784445
include Rails.application.routes.url_helpers
def test
STDERR.puts self.upload
STDERR.puts "nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn"
end
def to_jq_upload
{
"name" => read_attribute(:upload_file_name),
"size" => read_attribute(:upload_file_size),
"url" => upload.url(:original),
"delete_url" => upload_path(self),
"delete_type" => "DELETE"
}
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment