Permalink
Browse files

Can have one list per model (was: one list for all).

  • Loading branch information...
1 parent 5621003 commit 388bfbac69bf9dd3977fdebb54173289bb6a9830 @anwajler anwajler committed Jul 19, 2011
Showing with 3 additions and 3 deletions.
  1. +3 −3 lib/campaign_monitor_subscriber.rb
@@ -3,20 +3,20 @@ module CampaignMonitorSubscriber
CM_CONFIG = YAML::load_file(File.join("config/campaign_monitor_subscriber_config.yml"))
::CAMPAIGN_MONITOR_API_KEY = CM_CONFIG['api_key']
- def subscribe_me_using(email_field, custom_fields={})
+ def subscribe_me_using(email_field, custom_fields={}, list_name="id")
return if CM_CONFIG[::Rails.env] == false
after_create do |record|
begin
custom_fields = custom_fields.inject({}) { |h, (k, v)| h[k] = record.send(v); h }
s = Campaigning::Subscriber.new(record.send(email_field), custom_fields["name"])
- s.add!(CM_CONFIG['list_id'], custom_fields)
+ s.add!(CM_CONFIG["list_#{list_name}"], custom_fields)
rescue RuntimeError
end
end
after_destroy do |record|
begin
- Campaigning::Subscriber.unsubscribe!(record.send(email_field), CM_CONFIG['list_id'])
+ Campaigning::Subscriber.unsubscribe!(record.send(email_field), CM_CONFIG["list_#{list_name}"])
rescue RuntimeError
end
end

0 comments on commit 388bfba

Please sign in to comment.