Sign in through GitHub

RailsCasts Pro episodes are now free!

Learn more or hide this

tybro0103's Profile

GitHub User: tybro0103

Comments by


Have you considered doing an episode on the rest of Stripe Integration? Things like:
upgrades, downgrades, cancellations, receiving webhooks, updating cc info, handling failed payments, etc.? I've built several subscription sites with and these things are always such a pain. I would love find out if there are any best practices and see how other Rails developers handle such things.


Unless your code is open source, I wouldn't bother with that. I prefer to store those setting in environment files.

production.rb: STRIPE_SECREY_KEY = "XXXX"
development.rb: STRIPE_SECREY_KEY = "YYYY"
initializers/stripe.rb: Stripe.api_key = STRIPE_SECRET_KEY

Now if your code is open source... yes.


Braintree looks way better than say, but Stripe has these advantages:
- Developer friendly, less headaches
- No monthly fees
- Very easy setup


@1. I was wondering the same. Values like that are prone to change so it's best to have them in some sort of global variable. I had always used the approach:

Stripe.setPublishableKey('<%= STRIPE_PUBLIC_KEY %>')

I see one advantage to the meta tag version in that you don't have to give your coffeescript file an .erb extension. This can confuse certain text editors. Other than that, I can't figure out why he would have used a meta tag.


My ugly, and hopefully temporary, fix: = function() {
var url = Mercury.saveURL ? Mercury.saveURL : this.iframeSrc();
var data = this.serialize();
Mercury.log('saving', data);
if(this.options.saveStyle != 'form') data = jQuery.toJSON(data);
var method = (this.options.saveMethod == 'PUT') ? 'PUT' : 'POST';
jQuery.ajax(url, {
type: method,
dataType: this.options.saveDataType || 'json',
data: {_method: method, content: data},
success: function() {
Mercury.changes = false;
error: function() {
alert("Mercury was unable to save to url:\n"+url);

The missing line was:


Same here... this is driving me crazy! I've tried everything I can think of to get the access to saved event... nothing is working.


I figured it out:

  constraints subdomain: /.+/ do
    scope :module => "sites" do
      root :to => 'public#welcome'

  root :to => 'public#welcome'

Yeah, I'm doing that right now, but it seems like it will become tedious when I have a lot of controllers. Also, how would I define a resource, say "Post", where the controller is at controllers/sites/posts_controller.rb ?

I think I may have found my answer here actually:
...about to try it out now.


Great screencast!

I'm trying to do something similar to the subdomain trick you just showed, but I want to change the controller that's used rather than the view. Is this possible?

I'm making a CMS where a user can create a site and enter their own subdomain. I'd like "/" to point to "public#welcome" if there's no subdomain, but if there is a subdomain, I want it to point to "sites/public#welcome".