Chris Oliver


258,750 Experience
22 Lessons Completed
283 Questions Solved


Hey Alfred,

Can you post your actual error?

Posted in Security Hardening Servers with Fail2Ban Discussion

Not by default, it's too easy for people to lock themselves out if they aren't familiar with using SSH. We definitely encourage you to install it if you want. 👍

Posted in Recurring events with the ice_cube gem Discussion

Yeah, there's not a real easy way when the schedules are dynamically generated.

Posted in foreman issues

If you read the Foreman README, they recommend you don't put it in your Gemfile. Just gem install foreman globally.

That would come from a has_may :authors association. ActiveRecord knows how to handle those associations through those methods.

It's documented here as collection_singular_ids

You can't save street to the Patient model if you don't have have a column with that name.

You said you were using a separate table to store the addresses, so you would need to use a nested form to fill out Patient and Address details at the same time.

Hey Thomaz,

You can simply access the data through the Patient association to Address.

<%= patient.address.street %>

Posted in Import into administrate?

Imports are usually pretty unique to your app, so I imagine they intend it to be that way since your format may not exactly match the database table.

There's several episodes here on GoRails talking about importing from CSV. I'd recommend checking those out and building that out for importing with Administrate.

Nothing too fancy. users/edit comes from Devise. password/edit is a passwords controller I added.

Depends on how up-to-date you want it to be. If you're fine with every day, then write a cron job to sync and update every day or something.

If you need it to be more real-time, then trigger an API request after you load the record to sync it with the latest value. They may also provide webhooks to send you the changes as needed which you would save you from making API requests which would be nice.

Posted in rails migration warnings

Totally fine and part of running Ruby 2.7.0 with Rails right now. They're just warnings like it says and it will be updated in Rails core shortly.

Hey Taylor, I agree that you should definitely use columns. I'm actually working on this functionality for Jumpstart Pro as we speak. 😜

Hey Ali,

This is a great question. What I would probably do for this is I would create a model that would cache the results of the API call.

Then I would use a before_action in ApplicationController to load that model for the current user. If it didn't exist, you can have it hit the API and save the results in the model.

The first request, the model shouldn't exist, but every time afterwards it will so you won't have to hit the API every time.

I wouldn't use the after_authentication hook exclusively just because there may be situations that come up where that method doesn't succeed and a user might not have any results. Imagine that external service went down for an hour or they returned a 500 error for some reason. If you do it every request instead, you can always hit their API as needed without worrying about missing records ever.

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.

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.

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.

logo Created with Sketch.

Ruby on Rails tutorials, guides, and screencasts for web developers learning Ruby, Rails, Javascript, Turbolinks, Stimulus.js, Vue.js, and more. Icons by Icons8

© 2021 GoRails, LLC. All rights reserved.