Remember the example refresh_from_spreedly method on your User object?
def refresh_from_spreedly
subscriber = Subscriber.find(self.id)
self.update_attributes(:active => subscriber.active, :spreedly_token => subscriber.token)
rescue ActiveResource::ResourceNotFound
self.update_attribute(:active, false)
end
Why are we remembering the :token attribute of the subscriber? Well, that field is used to generate the “subscriber account” url that you may want to show up on your site. Let’s say your customer purchases a recurring subscription. Then later they want to change some things like
The “subscriber account” url allows them to make these changes. It looks like this:
https://spreedly.com/meresheep/subscriber_accounts/4064324532972e2e1165628630f178ec242e3734
where meresheep should be replaced with your url suffix and 4064324532972e2e1165628630f178ec242e3734 should be replaced with the token of the subscriber in question.
So in Rails, you could have a method on your User object like so:
def spreedly_account_url
"https://spreedly.com/meresheep-test/subscriber_accounts/#{self.spreedly_token}"
end