Sha256: bb10755ba128f93713f45433fc24b13018fb8d08e267d724cc9b3ef9218ef7e0
Contents?: true
Size: 897 Bytes
Versions: 1
Compression:
Stored size: 897 Bytes
Contents
require 'mime/types' class Transit::AssetsController < TransitController before_filter :update_params, :only => [:create, :update] respond_to :js, :json, :html skip_before_filter :verify_authenticity_token def create @asset = Transit::Asset.new(params[:asset]) @parent = params[:resource_type].constantize.find(params[:resource_id]) @asset.assetable = @parent @asset.save flash[:success] = "Upload successful!" respond_with(@asset) end def show @asset = Transit::Asset.find(params[:id]) end def update end def destroy @asset = Transit::Asset.find(params[:id]) @asset.destroy respond_with(@asset) end private def update_params return true unless params[:asset][:file] params[:asset][:file].content_type = ::MIME::Types.type_for(params[:asset][:file].original_filename).first.to_s end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
transit-0.0.2 | app/controllers/transit/assets_controller.rb |