Rails 新手,我正在通过 Gibbon 连接到 Mailchimp API。
我想将我的应用程序的订阅者添加到邮件列表中,而无需他们签署两次确认。因此,当在 Devise::RegistrationsController 中创建新用户时,我已将 API 调用添加到 Mailchimp。但是,我想一旦他们从确认电子邮件中确认,它实际上应该被添加。但我看不到在 Devise::RegistrationsController 中正确执行此操作的位置。这是我现有的代码...谢谢。
class RegistrationsController < Devise::RegistrationsController
def new
super
end
def create
super
if resource.save
# Add the new user email to Mailchimp
# double-optin is part of the Mailchimp API that sends/doesn't send a confirmation email
# in this case I'm already sending a confirm signup email
# which already informs them they'll be added to a mailing list
gb = Gibbon.new('my-mailchimp-api')
gb.list_subscribe({:id => 'my-mailchimp-list-id',
:email_address => resource.email,
:merge_vars => {:FNAME => resource.forename, :LNAME => resource.surname },
:double_optin => "false"})
end
end
def edit
super
end
def update
super
end
def destroy
super
end
def cancel
super
end
protected
def update_needs_confirmation?(resource, previous)
super
end
def build_resource(hash=nil)
super
end
def sign_up(resource_name, resource)
super
end
def after_sign_up_path_for(resource)
super
end
def after_inactive_sign_up_path_for(resource)
super
end
def after_update_path_for(resource)
super
end
def authenticate_scope!
super
end
def sign_up_params
super
end
def account_update_params
super
end
end