Chris Oliver

Joined

291,480 Experience
86 Lessons Completed
296 Questions Solved

Activity

  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])

Posted in Stripe integration on Ruby On Rails

Hey Raphael,

Basically like they said, you'd just create the source rather than passing it in to the subscription

customer = Stripe::Customer.create
customer.sources.create(source: params[:stripeToken])
customer.subscriptions.create(plan: params[:plan])

Posted in Multi tenancy for one type of user

Honestly, the thing that scales best and is easiest to do for just about all "multitenancy" is to just build it at an application level. Use pundit to verify that someone trying to access the vendor section has permissions.

Multitenency is really more for when you absolutely can't have two customer's data in the same database. Think situations like you are dealing HIPAA or something like that where you are collecting very private data.

In most cases, you just want to scope queries and add permissions to separate out parts of your app to specific users. For example, the vendor section you're talking about. If a user is marked as a vendor, then when they visit the vendor area, they only see their products. And if you want to scope it by domain, lookup the domain and verify if the user has permission, if not redirect them to theirs.

Posted in How do I handle this race condition?

Just your standard ActiveJob features: MyJob.set(wait: 30.seconds).perform_later

And in the job, try to find if the file exists, if not, schedule the job again with the same args.

Roughly:

class MyJob < ApplicationJob
  def perform(file_id, retry_count=0)
      file = lookup_file(file_id)
        if file.present?
          # process
        elsif retry_count < 10 # maximum number of retries
            MyJob.set(wait: 30.seconds).perform_later(file_id, retry_count + 1)
        end
    end
end

Posted in How do I handle this race condition?

Sounds like a terrible webhook lol.

You can always have the webhook schedule a job for 30 seconds in the future or something. If it still can't find it, schedule another job 30 seconds in the future, until it finds it or hits a maximum number of retries.

Posted in Passenger vs Puma

It's about 100x easier for anyone new to running their own Rails apps. It's far more helpful when things go wrong with it's nice error pages and everything. That's the main reason.

Learning should start with the easy way to get started and then work your way up. Most of the support requests I get on Hatchbox come from people using Puma with know knowledge of how to use or debug it. That doesn't happen with Passenger since it just works and doesn't require any special setup. Puma requires you to run it as a separate service, unix sockets, gotta read the logs to find out why it's not running, etc. Not near as user friendly, but that's why they can charge money for Passenger.

It's also faster than Puma if you pay for Passenger Enterprise, but it can be costly. Since it's written as an NGINX module, it's running C code, not Ruby. https://www.rubyraptor.org/how-we-made-raptor-up-to-4x-faster-than-unicorn-and-up-to-2x-faster-than-puma-torquebox/ "Raptor" was their codename for Passenger 5.

Puma is free, so most people like that for obvious reasons. There are lots of blog posts on both, so you can make the decision on what you want to use.

Posted in Liking Posts Discussion

The base project is generally using https://github.com/excid3/jumpstart

Posted in Why Wistia?

Sadly pretty much all video is gonna be fairly expensive. You can look at Vimeo or just rolling your own with AWS S3 and using access permissions / presigned url. You'll have to have your own player for S3, like video.js or something. There are a few other options out there like bitmovin, but it's gonna depend a bit on how much you want to pay vs roll your own.

Posted in Payments with Stripe Master Class

Hey Brian!

I would just use Rails.env in your line there to make it dynamic. Should be something like this:

<%= tag :meta, name: "stripe_key", content: Rails.application.credentials[Rails.env][:stripe_publishable_key] %>

Posted in Setup Windows 10 Discussion

Hey John, not sure why that command doesn't work from you. I just pasted in the RVM installation instructions from their website. I don't use RVM though but as long as you get the gpg keys imported, that's all you need.

Hey Andrei,

Currently, it's just me and that's something you'll need to consider. Hopefully it'll make enough money to afford a team in the long run. If you decide to cancel your subscription, you won't be able to deploy anymore but your app will continue running.

Posted in How to change Boolean Value on specific date.

Hey Jeff,

Have you seen this episode? https://gorails.com/episodes/scheduling-posts It does this without extra complication.

Otherwise you could use a background job or cron job to toggle it, but that's probalby overkill unless you can't use the above option for some reason.

Posted in Setup Windows 10 Discussion

Alberto, yep. You'll always need libpq-dev to compile the C extension for Ruby to talk to Postgres. 👍

Make sure your User validations are passing. We only validate the email and password in this example so if you've required other fields, your User won't be saved.