Class: CollavrePlan::CreativePlansController
- Inherits:
-
ApplicationController
- Object
- Collavre::ApplicationController
- ApplicationController
- CollavrePlan::CreativePlansController
- Defined in:
- app/controllers/collavre_plan/creative_plans_controller.rb
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'app/controllers/collavre_plan/creative_plans_controller.rb', line 5 def create result = tagger.apply respond_to do |format| format.html do flash[result.success? ? :notice : :alert] = ( result, success_key: "collavre.creatives.index.plan_tags_applied", success_default: "Plan tags applied to selected creatives.", failure_key: "collavre.creatives.index.plan_tag_failed", failure_default: "Please select a plan and at least one creative." ) redirect_back fallback_location: Collavre::Engine.routes.url_helpers.creatives_path(select_mode: 1) end format.json do if result.success? render json: { message: (result, success_key: "collavre.creatives.index.plan_tags_applied", success_default: "Plan tags applied.", failure_key: "", failure_default: "") }, status: :ok else render json: { error: (result, success_key: "", success_default: "", failure_key: "collavre.creatives.index.plan_tag_failed", failure_default: "Failed to apply plan.") }, status: :unprocessable_entity end end end end |
#destroy ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'app/controllers/collavre_plan/creative_plans_controller.rb', line 28 def destroy result = tagger.remove respond_to do |format| format.html do flash[result.success? ? :notice : :alert] = ( result, success_key: "collavre.creatives.index.plan_tags_removed", success_default: "Plan tag removed from selected creatives.", failure_key: "collavre.creatives.index.plan_tag_remove_failed", failure_default: "Please select a plan and at least one creative." ) redirect_back fallback_location: Collavre::Engine.routes.url_helpers.creatives_path(select_mode: 1) end format.json do if result.success? render json: { message: (result, success_key: "collavre.creatives.index.plan_tags_removed", success_default: "Plan tag removed.", failure_key: "", failure_default: "") }, status: :ok else render json: { error: (result, success_key: "", success_default: "", failure_key: "collavre.creatives.index.plan_tag_remove_failed", failure_default: "Failed to remove plan.") }, status: :unprocessable_entity end end end end |