Chris Oliver

Joined

292,890 Experience
93 Lessons Completed
295 Questions Solved

Activity

Posted in Comments With Polymorphic Associations Discussion

Been planning on doing that soon. Thinking about doing this in a series where we create an embeddable Javascript comment system like Disqus.

Posted in Looking for Rails work? / Hiring Rails developers?

My friend at Airbnb is hiring as well. His team is working specific on accessibility. Here's a generic job description for anyone interested: https://www.airbnb.com/careers/departments/position/2192

Posted in Why Wistia?

Hey James,

I think it should be really easy. The APIs you only need if you need to get a list of videos that are hosted or something.

You can hack something really easy together by just taking an embed code for a video and just simply replacing the video ID with an attribute stored on your model.

A pseudocode example of embedding Vimeo in Rails dynamically:

<iframe src="http://vimeo.com/embed/<%= @video.vimeo_id %>"></iframe>

This is how I do it with Wistia. I just set the ID in my admin area for a new episode. The only time I use the Wistia API is to make that easier. I upload the video, then use the API to populate a select dropdown with the videos that are uploaded so I can search and find the ID quicker.

Posted in API Authentication with an OAuth Provider Discussion

In the screencast, I just commented out the before_action so I could show the JSON it renders. You won't be able to access the URL directly unless you make the request with your token. You can use Postman to try it out, or just uncomment the doorkeeper before_action like I did.

Posted in JWT with Devise (App and API)

Hey Stephen, did you see the series on how to build an OAuth Provider in Rails? It integrates with Devise, it will generate JWTs for access tokens if you want, and you can use it with iOS and Android to provide a "Login with My App" process just like Twitter or Facebook which is cool.

Posted in rails generate devise:install hangs

Try running "spring stop" in the new app folder, delete the folder, and then try again. Spring will cache files like that and do weird things.

Sebastian, you can always build custom buttons for Trix to add those features.

Posted in Paypal & Stripe

Hey Brian,

Where's your confusion?

A webhook is sending you some JSON data, so you have to poke around through it to get what you want out (the amount in this case).

Your error says you called amount on a Stripe Subscription which doesn't have an amount, a plan does.

NoMethodError (undefined method `amount' for #Stripe::Subscription:0x00005630b03da5b8)

Print out your event in the terminal or byebug / pry it so you can see what data you've got.

Posted in Paypal & Stripe

You're calling charge.amount on the stripe object you set just before with:

charge = event.data.object

Since that's a Subscription object, you can call methods on it for the attributes it has. This is not your model.

https://stripe.com/docs/api#subscription_object

As you can see, you can ask that object for the plan, and then the plan for the amount.

Posted in Paypal & Stripe

Looks like it doesn't support it directly, it must be nested inside an html key. You can see under the "form_with options" header here: https://api.rubyonrails.org/v5.1/classes/ActionView/Helpers/FormHelper.html#method-i-form_with

Either way, that works fine though. 👍

Posted in Exporting Records To CSV Discussion

Yep, that's pretty normal for very large files. Generate it, store it somewhere that you can link to, and then either send them an email or display it on the website with a link to download. That's pretty standard to what you'd see in other apps.

Posted in Paypal & Stripe

Hey Brian,

So the existing card form shows up but it doesn't hide the new card form? Is that correct?

For some debugging, just print out the results of things like <%= current_user.card_last4? %> to make sure it is true. Then try just adding a simple like style: "background: blue" to your form and make sure you've got that working. Then go swap it out with the conditional version, since you'll probably have discovered what's wrong then.

Posted in User Referral Program From Scratch Discussion

I love when that happens!

  1. If you want a fully managed affiliates, then they're going to have to do that. They've got to monitor every new user and charge that comes in to verify they were referrals.
  2. They're manual at the moment via PayPal (or however you want to pay), but will be automated in the future.

I will be, but I have to split out the products into separate Stripe accounts before I can do that it looks like.

Posted in Paypal & Stripe

Hey Brian,

So for PayPal, I actually use Braintree. I've got it setup so I don't use their form, but rather trigger the PayPal checkout from a link. You can check out the Braintree episode I did on GoRails for that. I am using the Braintree JS v2 still, as it looks like they came out with v3 that doesn't support the same feature.

https://gorails.com/episodes/braintree

It's just a lot easier to integrate with Braintree than it is to use PayPal directly, and PayPal purchased Braintree a few years ago.

Posted in How do I find the next and previous lesson?

The acts_as_list gem has some methods for inserting and moving items in a list. It updates all the values afterward if you were to insert an item at position 2 like you mentioned. You'd need to make those updates in a transaction so it would undo all of them if any one failed.

In fact, you might just want to use that gem. It comes in handy so you don't have to reinvent the wheel on any of that.

Posted in Using Webhooks with Stripe Discussion

It should automatically load that file as long as you named it correctly. class WebhookHandlers::StripeWebhookHandler; end

Posted in Rails Application Templates Discussion

Hmmm, it sounds like Administrate didn't generate a dashboard file for the Announcement model. That's weird.

Posted in Stripe integration on Ruby On Rails

You need to save the new subscription to a variable.

subscription = customer.subscriptions.create(plan: params[:plan])