Chris Oliver


234,920 Experience
17 Lessons Completed
256 Questions Solved


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


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] 

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.

Posted in Hatchbox Postgres Problem

You should use the Hatchbox support link instead of posting in the GoRails forum.

Sounds like Postgres isn't running. Hatchbox doesn't fully manage your Postgres server for you, but it will install it and start it up.

I checked out your server and Postgres crashed because your server ran out of memory. You may need to upgrade to the next server size.

Hiding vs removing the tag in the HTML doesn't really make any difference. Just have to make sure that only admins are allowed on the server side of the request.

Posted in Question About Railties, rails repo and rails gems

It is a bit strange, but yes, they do use it as a monorepo. All the code for ActiveRecord is in the activerecord folder and so on. Each of those folders is a gem and gets published along with the Rails release.

The reason they do this is because they have to coordinate releasing all these gems at the same time with each new Rails release. This helps keep things consistent since they can keep track of it all in one place. Rails 6.1 can release updates for every gem with one command since it's all in the same repo.

I like app/validators. You can easily add in more there as needed and it's nicely organized. 👍

Posted in How do I style select options?

I think you have to use a Javascript library to create a custom select box like that. The browser's select box does not allow you to do that.

For example, something like this provides a ton of flexibilty: or

Posted in Phusion Passenger error on Hatchbox

You can use -n 300 to with tail to display 300 lines of logs. By default it only shows a small handful.

Posted in Phusion Passenger error on Hatchbox

Is there more to the stacktrace? This doesn't look like a complete one.

Posted in How do I resolve this syntax error

Presumably you meant options to be a hash? You used () instead of {}

options = {

Doh! You can delete the file and generate new credentials. That's probably the easiest option and then you can save the .key file somewhere safe this time. 😅

Hey Jim!

Since the credentials file contains API keys and other secrets, only the encrypted file gets stored in git. The matching config/credentials.key contains the key to decrypt that file. The key should not be stored in the repo, otherwise it wouldn't be secure and you might as well store the keys in plain text.

So you'll have to grab the config/credentials.key file from your other computer and add it to your laptop.

Keep that key safe like a password. It's the only way to decrypt the credentials.

For background jobs on Ubuntu, you would normally use SystemD.

With sidekiq, you would:

  1. Add the Sidekiq systemd script to /etc/systemd/system/sidekiq.service
  2. sudo systemctl daemon-reload
  3. sudo systemctl enable sidekiq
  4. sudo systemctl start sidekiq

daemon-reload refreshes systemd so it sees the new service.
enable allows it to start when the server boots.
start starts sidekiq

You then want to run sudo systemctl restart sidekiq on deploy so it can pickup the latest Rails code for the jobs.

Posted in PAGY with Rails API Only

Hey Tim,

Normally, you want to pass the next page number into the URL like you mentioned. That's how pagination links work when you display render them. Then the server knows which group of 20 records to grab next.

Rails always sanitizes rendering HTML by default, so it should be fine. Rendering ActionText content is also sanitized and you can use the sanitize helper anytime you want to be sure it gets sanitized.

You just do not want to ever use html_safe or raw which will introduce XSS vulnerabilities because it will not escape content if you use them.

Looks like it's using for the domain so you're probably missing one of the configs to set the default host.

Lots of chat about it in this thread.

And one of the recommended options to try is:

config.active_storage.service = :local
config.action_mailer.default_url_options = { host: '' }
config.default_url_options = { host: "" }
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

© 2020 GoRails, LLC. All rights reserved.