Class: Caboose::RetargetingController

Inherits:
ApplicationController show all
Defined in:
app/controllers/caboose/retargeting_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#add_ga_event, #admin_add, #admin_bulk_add, #admin_bulk_delete, #admin_bulk_update, #admin_delete, #admin_index, #admin_json, #admin_json_single, #before_before_action, #hashify_query_string, #init_cart, #logged_in?, #logged_in_user, #login_user, #logout_user, #parse_url_params, #reject_param, #under_construction_or_forwarding_domain?, #user_is_allowed, #user_is_allowed_to, #validate_cookie, #validate_token, #var, #verify_logged_in

Instance Method Details

#admin_editObject



14
15
16
17
18
19
20
21
# File 'app/controllers/caboose/retargeting_controller.rb', line 14

def admin_edit
  return if !user_is_allowed('sites', 'edit')       
  if !@site.is_master
    @error = "You are not allowed to manage sites."
    render :file => 'caboose/extras/error' and return
  end      
  @site = Site.find(params[:site_id])
end

#admin_updateObject



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'app/controllers/caboose/retargeting_controller.rb', line 24

def admin_update
  render :json => { :error => "You are not allowed to manage sites." } and return if !user_is_allowed('sites', 'edit') || !@site.is_master
  
  resp = StdClass.new     
  site = Site.find(params[:site_id])
  rc = site.retargeting_config

  params.each do |name,value|
    case name          
      when 'google_conversion_id'   then rc.google_conversion_id   = value    
      when 'google_labels_function' then rc.google_labels_function = value
      when 'fb_pixel_id'            then rc.fb_pixel_id            = value
      when 'fb_vars_function'       then rc.fb_vars_function       = value
	  end
	end
	
	resp.success = rc.save
	render :json => resp
end

#before_actionObject



9
10
11
# File 'app/controllers/caboose/retargeting_controller.rb', line 9

def before_action
  @page = Page.page_with_uri(request.host_with_port, '/admin')
end