Class: Caboose::AbOptionsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- Caboose::AbOptionsController
- Defined in:
- app/controllers/caboose/ab_options_controller.rb
Instance Method Summary collapse
-
#admin_create ⇒ Object
POST admin/ab-variants/:variant_id/options’.
-
#admin_delete ⇒ Object
DELETE /admin/ab_options/:id.
-
#admin_index ⇒ Object
GET /admin/ab_variants/:variant_id/options.
-
#admin_update ⇒ Object
PUT /admin/ab_options/:id.
Methods inherited from ApplicationController
#admin_add, #admin_bulk_add, #admin_bulk_delete, #admin_bulk_update, #admin_edit, #admin_json, #admin_json_single, #before_action, #before_before_action, #hashify_query_string, #init_cart, #logged_in?, #logged_in_user, #login_user, #logout_user, #parse_url_params, #reject_param, #user_is_allowed, #user_is_allowed_to, #validate_cookie, #validate_token, #var, #verify_logged_in
Instance Method Details
#admin_create ⇒ Object
POST admin/ab-variants/:variant_id/options’
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'app/controllers/caboose/ab_options_controller.rb', line 13 def admin_create return unless user_is_allowed_to 'edit','ab_variants' resp = StdClass.new({ 'error' => nil, 'redirect' => nil }) opt = AbOption.create( :ab_variant_id => params[:variant_id], :text => params[:text] ) resp.redirect = "/admin/ab-variants/#{params[:variant_id]}" render :json => resp end |
#admin_delete ⇒ Object
DELETE /admin/ab_options/:id
50 51 52 53 54 |
# File 'app/controllers/caboose/ab_options_controller.rb', line 50 def admin_delete return unless user_is_allowed_to 'delete', 'ab_variants' AbOption.find(params[:id]).destroy render :json => true end |
#admin_index ⇒ Object
GET /admin/ab_variants/:variant_id/options
6 7 8 9 10 |
# File 'app/controllers/caboose/ab_options_controller.rb', line 6 def admin_index return unless user_is_allowed_to 'view', 'ab_variants' v = AbVariant.find(params[:variant_id]) render :json => v. end |
#admin_update ⇒ Object
PUT /admin/ab_options/:id
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'app/controllers/caboose/ab_options_controller.rb', line 30 def admin_update return unless user_is_allowed_to 'edit', 'ab_variants' resp = StdClass.new opt = AbOption.find(params[:id]) save = true params.each do |k,v| case k when 'value' opt.value = v break end end resp.success = save && opt.save render :json => resp end |