Stripe Elements and Turbolinks 5

I was having a hell of a time getting Stripe Elements to work with Turbolinks 5, specifically the Turbolinks iOS wrapper. Hopefully others who see the same issues can benefit from what I learned.

The symptoms were:

  • Stripe Elements worked in the desktop browser, in mobile safari, but not in the Turbolinks-enabled iOS app

What I learned:

  • For Turbolinks-enabled iOS apps, all forms must be sent via AJAX w/ remote: true (or the absence of local: true depending on your version of Rails)
  • When using rails-ujs, you must intercept the ajax:before event and call event.preventDefault until the Stripe JS library has had a chance to retrieve the token
  • Once the token has been retrieved and added to the form, you must call, 'submit')
  • In your interception of ajax:before this time, you must not call event.preventDefault() since you now have the token

For reference, here’s my javascript:

At least I learned a lot about how rails-ujs, turbolinks, and Stripe Elements work under the hood!


While reading Bureaucracy As Active Ingredient it struck me that there is a parallel here with the design of our federal government.

The article essentially explains that the cost of working through a bureaucracy is part of the design of a system that requires a high cost. Makes sense. A different kind of cost perhaps better suited to healthcare than simply charging more money.

I remember in my high school government class being taught that our federal government was designed to “check the best and worst impulses of man”. I’ve searched for this quote and while I seem to remember it coming from Thomas Jefferson, I can’t find any sources to back that up.

Nonetheless, I think this explains a lot about our current politics. What we have is essentially gridlock. And while that frustrates many people, I think it’s very important to remember that this is not a flaw. This is a design choice.

The framers saw the downside to a federal government with lots of power that was able to move quickly. And they wanted to make sure that anything really worth accomplishing passed the same sort of bar that Slate Star Codex describes in healthcare today.

And, remember, even if the majority of the population wants something accomplished, that shouldn’t actually be enough to simply allow the government to proceed. They’ve also got to watch out for the minority opinion, to keep their voices from being snuffed out.

(Coincidentally, I also think you can look at the electoral college through the same lens. The frequent calls for its abolition seem similarly misguided to me — it’s by design that the President isn’t elected by a direct vote.)

This is one of the reasons that I (personally) don’t really expect the government to accomplish anything for me. Expecting it to move fast and get things accomplished goes completely against the design of the system and the intent of the framers.

However, if enough people really believe that something ought to be done, then it’s possible for them to band together, strategize, and get it done. And if they are successful in working through the gridlock, then the results of their accomplishment will endure. For decades if not centuries.

If you haven’t seen the movie Lincoln, I can’t recommend it enough. Aside from being entertaining and dramatic, it’s also a terrific reminder of how difficult it was to get anything of meaning accomplished in the federal government, such as abolishing slavery! One of the reasons I love the movie so much is because the important characters never once complain about the government or about politics while working incredibly hard to get something of immense meaning accomplished.

They still believed in the system even though much of the country (in their eyes) was so very wrong about their attitudes.

For my money I can’t think of a better clip to share than this:

Weekly Round-up

Favorite links from this week:

I abandoned The Rise of Victimhood Culture 15% through. I think it makes many good points, but also contains a lot of weak arguments. And, it could be a blog post or article instead of a 278 page book. I did highlight a lot.

I also finished reading Brad Feld’s book Startup Communities that gave me a lot to think about w/ regard to non-SV startups.