Sha256: b761ecfdb03db8e05bffa467d41b3acebe52446489cd9ac1fce39094b7e83950

Contents?: true

Size: 1015 Bytes

Versions: 14

Compression:

Stored size: 1015 Bytes

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]
      self.assetable_id = params[:assetable_id]
      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

14 entries across 14 versions & 2 rubygems

Version Path
rails-uploader-0.1.0 lib/uploader/asset.rb
rails-uploader-0.0.8 lib/uploader/asset.rb
sunrise-cms-0.5.0.rc1 vendor/bundle/ruby/1.9.1/gems/rails-uploader-0.0.7/lib/uploader/asset.rb
rails-uploader-0.0.7 lib/uploader/asset.rb
rails-uploader-0.0.6 lib/uploader/asset.rb
rails-uploader-0.0.5 lib/uploader/asset.rb
sunrise-cms-0.3.3 vendor/bundle/ruby/1.9.1/gems/rails-uploader-0.0.1/lib/uploader/asset.rb
sunrise-cms-0.3.2 vendor/bundle/ruby/1.9.1/gems/rails-uploader-0.0.1/lib/uploader/asset.rb
sunrise-cms-0.3.1 vendor/bundle/ruby/1.9.1/gems/rails-uploader-0.0.1/lib/uploader/asset.rb
sunrise-cms-0.3.0 vendor/bundle/ruby/1.9.1/gems/rails-uploader-0.0.1/lib/uploader/asset.rb
rails-uploader-0.0.4 lib/uploader/asset.rb
rails-uploader-0.0.3 lib/uploader/asset.rb
sunrise-cms-0.3.0.rc vendor/bundle/ruby/1.9.1/gems/rails-uploader-0.0.1/lib/uploader/asset.rb
rails-uploader-0.0.1 lib/uploader/asset.rb