Chris Oliver

Joined

292,760 Experience
93 Lessons Completed
296 Questions Solved

Activity

Sounds like your MySQL server isn't running. Try starting it again.

Posted in How to version model validations for an API?

The reason APIs are versioned is because you can do these validations on the API level rather than in the model. You would say that in v2, we'd ignore the a parameter now, even if you still submitted it.

I'd recommend checking out some of the Stripe blog posts on API design. They have done a fantastic job of explaining how they do it. https://stripe.com/blog/api-versioning

And Stripe's APIs are by far some of the best designed for handling changes safely that don't break customer apps.

Posted in Reducing Transfer costs with AWS S3

That was fast! Also might want to look into Spaces' CDN. https://blog.digitalocean.com/spaces-now-includes-cdn/

Curious to hear how things go and if it helps keep costs down over the next few weeks.

Posted in Reducing Transfer costs with AWS S3

That's quite a lot. You probably are spending unncessary money doing this anyways if you're creating different sizes of images since you'll be downloading them from S3 after upload, creating your sized versions and uploading those back. That probably is extra cost. Spaces should be cheaper all around since it's not going to be going across the internet for that. Plus, Spaces is just cheaper all around.

$5/mo for Spaces includes 1TB of outbound traffic, so that may help by itself.

I don't know Cloudfront's pricing, but it may save some or add to the cost. It's going to be caching your files around the world with Cloudfront, so it's faster. If they're still charging you for bandwidth out, then may just be more expensive to use that.

You probably want to do some checking to make sure you're serving up the smallest images as much as you can and almost never serving the original upload. May want to add image compression as a step in your image processing as well. Possibly using Cloudflare's free CDN would help save some of the costs too if images can be cached in their CDN.

ActiveStorage isn't super great for this since all the requests for images go through Rails rather than being served directly from the S3 url. Rails 6.1 is going to have some official ways to link to files publicly, but I know there are a few hacks you can do for now to do that too.

Transfering to Spaces should be as simple as transferring all the files to Spaces and then updating the ActiveStorage endpoint to use Spaces. They're S3 compatible so it would be pretty easy, but you'd want to make sure you didn't miss any images that might get uploaded during the transfer. That might be the harder part if you don't want to pause new uploads temporarily.

Posted in Reducing Transfer costs with AWS S3

Have you checked your AWS account's billing information to see what's costing the most?

Posted in How to setup Emails, both transactional and Marketing

Yep, usually different because they'll build different tools. Convertkit and Mailchimp will let you design and send out newsletters but they're not really built for sending transactional stuff. And the opposite is true for the transactional email providers. Nobody is really doing both well right now. That might change in the future, but it seems like it's hard to offer both types in the same product.

Posted in how to move existing body content to use action text?

Thanks Alan! I'll have to try something like this on my local copy of GoRails and see how it goes.

Posted in how to move existing body content to use action text?

Awesome, let us know how it goes! And if it works, do you mind sharing the code?

Posted in how to move existing body content to use action text?

Yup, I had the same thing. I want to convert the GoRails forums over to it but now I'm like shoot...this is gonna be a lot of work to get right.

Posted in how to move existing body content to use action text?

That's a good question. I believe you'd have to convert your old content to HTML, then save it in the associated has_rich_text object. ActionText has its own model, so you would just create that record and that should make it available.

I haven't done this, so I don't have any code to point you in the right direction unfortunately.

Posted in Pipe convert out to Convert Input Minimagick

With a gem like image_processing, I believe you would just make two calls to do this. The first would want to save the output to the file so that the second could operate on its output. That way you won't have to use pipes in Ruby.

Very cool!

Since these aren't subscriptions, I don't believe you will be able to use Stripe Invoices or any of those features. Those I believe only work for subscriptions, so I guess that you will want something like this instead:

  • Reservation model with the due date.
  • One (or more) Payments related to the Reservation. This way you can keep track of the deposit and the final payment related to it.
  • Create the reservation after the payment is successful.
  • Email them reminders in a cron job about their upcoming due date and remaining balance (if any).

That's probably what I would do. Nothing too fancy.

What happens if they don't pay the balance? Do you just remove their access or something?

If these are subscriptions, Stripe Invoices have a "days_until_due" option. https://stripe.com/docs/api/invoices/create#create_invoice-days_until_due

If they're not subscriptions, I would just create a record to keep track of the order and the due date. If the current date is past the due_date, then you know it has elapsed.

You can then use a cron job to email the user warnings if it's 7 days till deadline, etc.

Twilio is a lot of fun. 🤓

Posted in Testing Controllers that call an activejob

Yeah, which is why my guess is that your test suite is referencing the wrong thing somewhere when it's trying to replicate the same thing.

Posted in Testing Controllers that call an activejob

Maybe you just forgot to change uninitialized constant Api::V1::ControllerName::JobName to match your class name?

There are lots of different types of notifications. A browser Notification in Javascript requires the user to be on the page. Email notification does not of course. Mobile typically requires a mobile app is installed and registered for notifications.

I'm fairly sure that mobile browser web push notifications in Javascript don't go through when the user is off the page. You'll probably need to do some research on that.

You can always send SMS or Slack notifications so the user would receive the messages through another form.

Posted in Ruby get GET request data

Jim,

You have to render a response through Rails. A puts is only going to print to the terminal. This doesn't work like PHP where it runs inside the HTML output, you have to actually build up the output in the response before Rails packages it up and sends it back.

If you're trying to render the URL params back out in the response, you would do:

def data
  render json: { 
      start_date: params[:start_date] 
    }
end

Posted in Hatchbox Postgres Problem

I logged into your server and restart postgres and your deploy succeeded now. sudo systemctl restart postgresql will restart it over SSH.