Activity
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.
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.
Hey Trevor,
That means your raw_info is returning nil. It should be returning an hash {}
.
Also I uploaded all the source code for these finally so you can reference my omniauth gem. I think I made some tweaks to it. https://github.com/gorails-screencasts/oauth-api-authentication
I'm not sure it's so worriesome. A markdown editor is super simple so unless there are a ton of bugs, there's not much maintenance that you would need.
Luckily HTML is valid Markdown, but like you see above, you can't really have Markdown in HTML because the characters will be escaped.
The problem with deleting the file after the user downloads it is that you then break the link. If they click the link again they'll get a 404 and you'll certainly end up with support calls dealing with that.
With email, you could generate the PDF and just email it over as an attachment. That way you wouldn't have to store a copy of the file and the user can always reference the file as long as they don't delete the email. This would probably be easiest to manage overall if you don't want to store the PDFs permanently on S3.
You would just use regular Ruby sort_by or sort_by! to sort the array that you get back from the API. https://apidock.com/ruby/Enumerable/sort_by