Sign in through GitHub

Please read for an updated status on RailsCasts:

Learn more or hide this

Richard Wiltshire's Profile

GitHub User: windcheetah

Comments by Richard Wiltshire

Avatar

Sorry for blowing up the board. I found the problem. One of the Twitter Bootstrap js files was conflicting with it. It is all working now.

Avatar

I took Justin's subscriptions.js file above and converted for new user and got the same results. Works fine in development mode but is essentially ignored in production mode. Other js files are working fine. Must be something in the asset pipeline configuration. Anybody else using this in production mode?

Avatar

Any reason this would not working in production mode? I know the code gets minified. I altered the code for new user but works great in development. I set break points in the deminified javascript and it is as it does not even get called. The new_user id is there in the HTML. This might be too heavy to post here but I feel it is something stupid that I missing. Thanks for any help. Here is a portion of the deminified javascript:

javascript
...

if (c.data("typeahead")) return;
b.preventDefault(), c.typeahead(c.data())
})
})
}(window.jQuery), function() {}.call(this), function() {
var a;
jQuery(function() {
return Stripe.setPublishableKey($('meta[name="stripe-key"]').attr("content")), a.setupForm()
}), a = {
setupForm: function() {
return $("#new_user").submit(function() {
return $("input[type=submit]").prop("disabled", !0), $("#card_number").length ? (a.processCard(), !1) : !0
})
},
processCard: function() {
var b;
return b = {
number: $("#card_number").val(),
cvc: $("#card_code").val(),
expMonth: $("#card_month").val(),
expYear: $("#card_year").val()
}, Stripe.createToken(b, a.handleStripeResponse)
},
handleStripeResponse: function(a, b) {
return a === 200 ? ($("#user_stripe_card_token").val(b.id), $("#new_user")[0].submit()) : ($("#stripe_error").text(b.error.message), $("input[type=submit]").prop("disabled", !1))
}
}
}.call(this);
Avatar

Ryan,

I had (and others on Overflow) an issue with stale or actually regenerated cookies. For instance. One login and the cookie is set with the :auth_code. If that cookie ever get out of sync with the db via regenerate or db reset the

User.find_by_auth_token!(cookies[:auth_token]) if cookies[:auth_token]

code will fail. You can simulate this by changing one letter in the :auth_code either in the cookie or db. I agree this should never happen, but when it does it is ugly. This will fix it but I think there is a better solution:

def current_user
begin
@current_user ||= User.find_by_auth_token (cookies[:auth_token]) if cookies[:auth_token]
rescue ActiveRecord::RecordNotFound
@current_user = nil
cookies.delete(:auth_token)
end
@current_user
end