<commit_before>= Devise MailChimp

Devise MailChimp adds a MailChimp option to {devise}[https://github.com/plataformatec/devise] that easily enables users
to join your mailing list when they create an account.

{Delayed Job}[https://github.com/collectiveidea/delayed_job] is used automatically if your project uses it, and the
mapping between list names and list ids is cached automatically.

== Getting started

In your Gemfile, add devise_mailchimp after devise:

  gem "devise"
  gem "devise_mailchimp"  # Last officially released gem

In your User model, add :mailchimp to the devise call:

  devise :database_authenticatable, ..., :mailchimp

In your devise initializer (config/initializers/devise.rb), set your API key and mailing list name:

  Devise.mailchimp_api_key = 'your_api_key'
  Devise.mailing_list_name = 'List Name'

If you are using the default Devise registration views, the Join Mailing List checkbox is added automatically, if not,
either include the form partial in your new registration form:

  <%= render :partial => "devise/shared/mailchimp/form", :locals => {:form => f} %>

Or manually add a "Join Mailing List" checkbox to your new registration form:

  <%=form.check_box :join_mailing_list%>

== Configuration

Create an initializer, and set your MailChimp API key.  To generate a new API key, go to the account tab in your
MailChimp account and select API Keys & Authorized Apps, then add a key.

  Devise.mailchimp_api_key = 'your_api_key'

Create a mailing list, and set the mailing list name in the initializer.  To create a MailChimp list, from your account
go to the Lists tab, then hit create list.

  Devise.mailing_list_name = 'List Name'

== Documentation

Full documentation is available at {rdoc.info}[http://rdoc.info/github/jcnnghm/devise_mailchimp/master/frames].

== Example Usage

Users will join the default mailing list if join_mailing_list is set to true when the user is created.  To manually add
a user:

  User.find(1).add_to_mailchimp_list('Site Administrators List')

To manually remove a user:

  User.find(1).remove_from_mailchimp_list('Site Administrators List')

NOTE:  You MUST have the users permission to add them to a mailing list.

== Customization

To have the user join more than one list, or to override the lists that the user will join, override
mailchimp_lists_to_join in your model.  Your method should return a single list, or an array of lists.

  def mailchimp_lists_to_join<commit_msg>Added demo app section<commit_after>= Devise MailChimp

Devise MailChimp adds a MailChimp option to {devise}[https://github.com/plataformatec/devise] that easily enables users
to join your mailing list when they create an account.

{Delayed Job}[https://github.com/collectiveidea/delayed_job] is used automatically if your project uses it, and the
mapping between list names and list ids is cached automatically.

== Getting started

In your Gemfile, add devise_mailchimp after devise:

  gem "devise"
  gem "devise_mailchimp"  # Last officially released gem

In your User model, add :mailchimp to the devise call:

  devise :database_authenticatable, ..., :mailchimp

In your devise initializer (config/initializers/devise.rb), set your API key and mailing list name:

  Devise.mailchimp_api_key = 'your_api_key'
  Devise.mailing_list_name = 'List Name'

If you are using the default Devise registration views, the Join Mailing List checkbox is added automatically, if not,
either include the form partial in your new registration form:

  <%= render :partial => "devise/shared/mailchimp/form", :locals => {:form => f} %>

Or manually add a "Join Mailing List" checkbox to your new registration form:

  <%=form.check_box :join_mailing_list%>

== Configuration

Create an initializer, and set your MailChimp API key.  To generate a new API key, go to the account tab in your
MailChimp account and select API Keys & Authorized Apps, then add a key.

  Devise.mailchimp_api_key = 'your_api_key'

Create a mailing list, and set the mailing list name in the initializer.  To create a MailChimp list, from your account
go to the Lists tab, then hit create list.

  Devise.mailing_list_name = 'List Name'

== Documentation

Full documentation is available at {rdoc.info}[http://rdoc.info/github/jcnnghm/devise_mailchimp/master/frames].

== Demo Application

A demo application is available at {github}[https://github.com/jcnnghm/devise_mailchimp_demo].

== Example Usage

Users will join the default mailing list if join_mailing_list is set to true when the user is created.  To manually add
a user:

  User.find(1).add_to_mailchimp_list('Site Administrators List')

To manually remove a user:

  User.find(1).remove_from_mailchimp_list('Site Administrators List')

NOTE:  You MUST have the users permission to add them to a mailing list.

== Customization

To have the user join more than one list, or to override the lists that the user will join, override
mailchimp_lists_to_join in your model.  Your method should return a single list, or an array of lists.

  def mailchimp_lists_to_join
{'fraction_non_alphanumeric': 0.06794770206022187, 'fraction_numerical': 0.000792393026941363, 'mean_word_length': 4.6730337078651685, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 13, 'https://': 5, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6454987', 'n_tokens_mistral': 1532, 'n_tokens_neox': 1460, 'n_words': 633}