Skip to content

Instantly share code, notes, and snippets.

@shayfrendt
Created July 22, 2011 14:05
Show Gist options
  • Save shayfrendt/1099512 to your computer and use it in GitHub Desktop.
Save shayfrendt/1099512 to your computer and use it in GitHub Desktop.
Sample Chargify Post-Back Controller
class Chargify::SubscriptionsController < ApplicationController
def update
subscription_ids = params['_json']
#Rails.logger.debug("SUB IDS: #{subscription_ids.inspect}")
begin
subscription_ids.each do |id|
# Process updated subscriptions here
Rails.logger.debug("SUB ID: #{id}")
end
respond_to do |format|
format.json { head :ok }
end
rescue # watch out, this will rescue everything! You may want to be more selective...
respond_to do |format|
format.json { head :internal_server_error }
end
end
end
end
# suggested corresponding named route for routes.rb
# map.chargify_subscriptions '/chargify/subscriptions/:action.:format', :controller => 'chargify/subscriptions'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment