ShelbyTV / shelby_gt

Rails API services for Shelby GT
2 stars 0 forks source link

Sailthru reintegration #169

Closed hsztul closed 11 years ago

hsztul commented 11 years ago

@spinosa take a look at this for me please.

updated: now pinging sailthru to see if a user is already in our system, if so, changing their email. otherwise just adding them to our list of gt-users.

only thing i am still not sure about is whether the callback on the user model should be a before_save or after_save

i dont think that user.primary_email_changed is preserved after save, but i am having a hard time verifying this in development.

additionally, the welcome email will be sent as a rake task run via cron (which i am still working on)

thanks,

spinosa commented 11 years ago

you should update user in after_save b/c you don't know if save will succeed in before_save. you can write a controller test to verify both cases

hsztul commented 11 years ago

so after some testing (wrote a function spec for user.rb) i believe i was correct, after_save we don't have access to any properties that have changed… so trying to ping sailthru doesn't work doing things with this callback.

any thoughts on how to proceed?

scratching my head.

On Friday, October 12, 2012 at 2:18 PM, Dan Spinosa wrote:

you should update user in after_save b/c you don't know if save will succeed in before_save. you can write a controller test to verify both cases

— Reply to this email directly or view it on GitHub (https://github.com/ShelbyTV/shelby_gt/pull/169#issuecomment-9385440).

spinosa commented 11 years ago

looks like it should work: http://stackoverflow.com/questions/3861777/determine-what-attributes-were-changed-in-rails-after-save-callback

hsztul commented 11 years ago

that did the trick. used after_update callback. thanks.