Sha256: 3d776f3449d164d455f5ac3dc2a154d60b09d477bafa8191c239e3b14c3532ad
Contents?: true
Size: 1.17 KB
Versions: 3
Compression:
Stored size: 1.17 KB
Contents
module Uploader module Asset # Save asset # Usage: # # class Asset < ActiveRecord::Base # include Uploader::Asset # # def uploader_create(params, request = nil) # self.user = request.env['warden'].user # super # end # end # def uploader_create(params, request = nil) self.guid = params[:guid] self.assetable_type = params[:assetable_type] if self.class.respond_to?(:collection) && !params[:assetable_id].blank? self.assetable_id = Moped::BSON::ObjectId.from_string(params[:assetable_id]) else self.assetable_id = params[:assetable_id] end save end # Destroy asset # Usage (cancan example): # # class Asset < ActiveRecord::Base # include Uploader::Asset # # def uploader_destroy(params, request = nil) # ability = Ability.new(request.env['warden'].user) # if ability.can? :delete, self # super # else # errors.add(:id, :access_denied) # end # end # end # def uploader_destroy(params, request) destroy end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
glebtv-rails-uploader-0.1.3 | lib/uploader/asset.rb |
glebtv-rails-uploader-0.1.2 | lib/uploader/asset.rb |
glebtv-rails-uploader-0.1.1 | lib/uploader/asset.rb |