has_many :lectures
attr_accessible :name
- has_attached_file :icon, :url => '/:attachment/:sha1.:extension', :use_timestamp => false
attr_accessible :icon, :icon_file_name
+ has_attached_file :icon,
+ :url => ':env_prefix/:attachment/:sha1.:extension',
+ :use_timestamp => false
include JsonWithoutTimestamps
def as_json(options = {})
icon_keys = [:icon_file_name, :icon_file_size, :icon_content_type, :icon_updated_at]
j = super options.merge({:except => (options[:except] || []) + icon_keys})
- j['icon_path'] = icon.url
+ j['icon_path'] = icon.exists? ? icon.url : nil
j
end
teacher = attachment.instance
Digest::SHA1.hexdigest "#{teacher.id}##{teacher.created_at.to_i}"
end
+
+Paperclip.interpolates :env_prefix do |attachment, style|
+ if Rails.env.production?
+ ''
+ else
+ "/#{Rails.env}"
+ end
+end