Skip to content

Instantly share code, notes, and snippets.

View justinthiele's full-sized avatar

Justin Thiele justinthiele

View GitHub Profile
@justinthiele
justinthiele / Readme.md
Created September 11, 2011 04:43
Retaining form data through a login process and resubmitting the form [Rails & Devise]

This is a feature I struggled with for quite awhile, so I thought I'd share my solution. The code is actually pretty simple once I got it figured out. Hopefully it will save somebody else some headaches.

So here's what we're doing

To create an easy on-boarding process, I've put a New List form on the front page of Favsi.com. However, creating a list requires the user to be authenticated, so I needed to create a way to retain the user's New List form data through the authentication/registration process, and then post it. Here's a screenshot of the front page: Favsi Front Page Form

The flow would go like this

  1. User goes to the front page.
  2. User fills out the New List form and presses the Create List button.
@justinthiele
justinthiele / subscriptions.js
Created October 23, 2011 19:17
For those who aren't using coffeescript, here is the compiled Subscriptions javascript file from RailsCast #288 Billing with Stripe
(function() {
var subscription;
jQuery(function() {
Stripe.setPublishableKey($('meta[name="stripe-key"]').attr('content'));
return subscription.setupForm();
});
subscription = {
setupForm: function() {
return $('#new_subscription').submit(function() {
$('input[type=submit]').attr('disabled', true);