RailsCasts Pro episodes are now free!
Learn more or hide this
GitHub User: Tref
Does anyone have any examples of using stripe in a nested form. For example I have a nested form that contains an affiliate which has_one subscription. This same affiliate also has a captcha. The problem is that that if i do something like
if @affiliate.subscription.save_with_payment && @affiliate.save_with_captcha
and there are errors with my affiliate model but not my subscription model, then the subscription gets saved without an affiliate_id, a customer is created by stripe and the same form re-renders populated with the stripe_token and the newly created subscription_id. Once the form is resubmitted and Affiliate.new(params[:affiliate] ) is called in the create action it is raising an error like Couldn't find Subscription with ID=31 for Affiliate with ID= since there is no affiliate_id in the subscription row in the DB. It would really be nice to see an example of this inside a nested form. Help!
Couldn't find Subscription with ID=31 for Affiliate with ID=
Was noticing that this was not doing anything to standardize the capitalizations so therefore tagname and Tagname are two different things in this implementation, in order to fix this I simply used a before_save to titleize the names with this:
self.name = self.name.titleize
Pretty simple but assigning of the name threw me for a loop for a minute. Great cast!