Class: Spree::Admin::VideoOnDemandsController
- Inherits:
-
ResourceController
- Object
- ResourceController
- Spree::Admin::VideoOnDemandsController
- Defined in:
- app/controllers/spree/admin/video_on_demands_controller.rb
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
16 17 18 19 20 21 22 23 24 25 |
# File 'app/controllers/spree/admin/video_on_demands_controller.rb', line 16 def create video_on_demand_params = params.require(:spree_cm_commissioner_video_on_demand) result = SpreeCmCommissioner::VideoOnDemandCreator.call(video_on_demand_params: video_on_demand_params) if result.success? redirect_to edit_admin_product_video_on_demand_url(product, result.video_on_demand) else flash[:error] = result.error render :new end end |
#edit ⇒ Object
12 13 14 |
# File 'app/controllers/spree/admin/video_on_demands_controller.rb', line 12 def edit @video_on_demand = SpreeCmCommissioner::VideoOnDemand.find(params[:id]) end |
#new ⇒ Object
7 8 9 10 |
# File 'app/controllers/spree/admin/video_on_demands_controller.rb', line 7 def new uuid = SecureRandom.uuid.gsub('-', '') @object = SpreeCmCommissioner::VideoOnDemand.new(uuid: uuid) end |
#update ⇒ Object
27 28 29 30 31 32 33 34 35 36 |
# File 'app/controllers/spree/admin/video_on_demands_controller.rb', line 27 def update @video_on_demand = SpreeCmCommissioner::VideoOnDemand.find(params[:id]) result = SpreeCmCommissioner::VideoOnDemandUpdater.call(video_on_demand: @video_on_demand, params: params) if result.success? redirect_to collection_url else flash[:error] = result.error render :edit end end |
#update_positions ⇒ Object
38 39 40 41 42 43 |
# File 'app/controllers/spree/admin/video_on_demands_controller.rb', line 38 def update_positions params[:positions].each do |id, index| video_on_demand = SpreeCmCommissioner::VideoOnDemand.find(id) video_on_demand.update(position: index) end end |