Class: Simplemde::AssetsController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/simplemde/assets_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



2
3
4
5
6
7
8
9
10
11
12
# File 'app/controllers/simplemde/assets_controller.rb', line 2

def create
  unless params[:file].blank?
    @asset = Simplemde::Image.new(asset: params[:file], asset_type: :image) # TODO file
    if params[:owner_id].present? && params[:owner_type].present?
      @asset.owner_id = params[:owner_id]
      @asset.owner_type = params[:owner_type]
    end
    @asset.save
    return render json: {filename: @asset.asset.url}
  end
end