scinote-web/app/controllers/marvin_js_assets_controller.rb

37 lines
827 B
Ruby
Raw Normal View History

2019-04-27 04:59:38 +08:00
# frozen_string_literal: true
class MarvinJsAssetsController < ApplicationController
def create
new_asset = MarvinJsAsset.add_sketch(marvin_params,current_team)
2019-04-28 01:08:40 +08:00
if new_asset.object_type == 'Step'
render json: {
html: render_to_string(
partial: 'assets/marvinjs/marvin_sketch_card.html.erb',
locals: { sketch: new_asset, i:0, assets_count: 0, step: new_asset.object}
)
}
else
render json: new_asset
end
2019-04-27 04:59:38 +08:00
end
2019-04-27 19:51:35 +08:00
def destroy
sketch=MarvinJsAsset.find(params[:id])
sketch.destroy
render json: sketch
end
2019-04-28 01:08:40 +08:00
def update
sketch=MarvinJsAsset.find(params[:id])
sketch.update(marvin_params)
render json: sketch
end
2019-04-27 04:59:38 +08:00
private
def marvin_params
2019-04-27 19:51:35 +08:00
params.permit(:description, :object_id, :object_type, :name)
2019-04-27 04:59:38 +08:00
end
end