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.

Revisions

  1. shayfrendt created this gist Jul 22, 2011.
    23 changes: 23 additions & 0 deletions sample_postback_controller.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,23 @@
    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'