Class: Admin::MailchimpController

Inherits:
ApplicationController
  • Object
show all
Includes:
Effective::CrudController
Defined in:
app/controllers/admin/mailchimp_controller.rb

Instance Method Summary collapse

Instance Method Details

#indexObject

/admin/mailchimp



11
12
# File 'app/controllers/admin/mailchimp_controller.rb', line 11

def index
end

#mailchimp_syncObject

Sync All



15
16
17
18
19
20
21
22
23
24
25
26
# File 'app/controllers/admin/mailchimp_controller.rb', line 15

def mailchimp_sync
  EffectiveResources.authorize!(self, :admin, :mailchimp_sync)

  api = EffectiveMailchimp.api
  Effective::MailchimpList.sync!(api: api)
  Effective::MailchimpCategory.sync!(api: api)
  Effective::MailchimpInterest.sync!(api: api)

  flash[:success] = "Successfully synced mailchimp data"

  redirect_back(fallback_location: effective_mailchimp.admin_mailchimp_path)
end

#mailchimp_sync_userObject

Sync one user



29
30
31
32
33
34
35
36
37
38
39
# File 'app/controllers/admin/mailchimp_controller.rb', line 29

def mailchimp_sync_user
  resource = current_user.class.find(params[:id])

  EffectiveResources.authorize!(self, :update, resource)

  resource.mailchimp_sync!

  flash[:success] = "Successfully synced mailchimp"

  redirect_back(fallback_location: "/admin/users/#{params[:id]}/edit")
end