Module: CatarseMailchimp::ActiveRecord

Defined in:
lib/catarse_mailchimp/active_record.rb

Instance Method Summary collapse

Instance Method Details

#sync_with_mailchimpObject

USAGE

# Simple example
class User < ActiveRecord::Base
  sync_with_mailchimp
end


9
10
11
12
13
14
15
16
17
18
19
# File 'lib/catarse_mailchimp/active_record.rb', line 9

def sync_with_mailchimp
  self.class_eval <<-RUBY
    after_save do
      if newsletter
        CatarseMailchimp::API.subscribe(self)
      else
        CatarseMailchimp::API.unsubscribe(self)
      end
    end
  RUBY
end