Chris Oliver


247,160 Experience
18 Lessons Completed
271 Questions Solved


Posted in New website design!

TailwindUI does have the Alpine JS examples on the site if you inspect the page I believe. And I agree, will definitely add this to my list of episode ideas!

Posted in How to add Notifications to Rails with Noticed Discussion

In the repo

Posted in How to add Notifications to Rails with Noticed Discussion

Of course, just add your own delivery method for it.

Posted in Reopen ActionCable after login?

You can also call anytime to connect.

Posted in Reopen ActionCable after login?

So, just tested this as I added multitenancy to ActionCable in Jumpstart Pro. I confirmed that ActionCable will attempt to connect automatically after you login because of the NotificationsChannel we added.

Posted in Mail Password hacked

Look at what processes are running on your server. They could have installed some software that runs on the server to send the emails out and if so you'd need to remove that.

Posted in Setup noticed to send emails through a mailer?

In your mailer you have:

mail(to: @post.recipient, subject: "My subject")

That should be

  mail(to: params[:recipient], subject: "My subject")


Posted in Hatchbox deployment. public/index.html not found

To run staging on your server, make sure you have RAILS_ENV=staging set in the env vars. 👍

Posted in Hatchbox deployment. public/index.html not found

You'd define it in config/routes.rb

root to: "controller#action"

In development, Rails will show the "welcome to Rails" screen, but in production that disappears and would 404 without a root route.

Posted in Hatchbox deployment. public/index.html not found

The Rails root path is what will be rendered first. If that isn't found, it'll fall back and look for index.html in the public folder. Normally you have a Rails root so the index.html would never be used.

Posted in How do I add ranges to my application?

Not off the top of my head, but I can make a screencast on it. 👍

Posted in How do I add ranges to my application?

You can either:

  1. Make a select that submits "1-10" to a virtual attribute on your model and use Ruby to split on "-" to get minimum and maximum and assign those.
  2. Use Javascript to take the select value and fill out hidden fields for minimum and maximum on the Select change event.

I typically use the second approach so I can keep the backend cleaner.

Posted in How do I add ranges to my application?

Hey Sam!

Databases don't understand Ranges like Ruby does, so instead you can add the minimum and maximum values of the range to the database and construct the range from that.

t.integer :minimum
t.integer :maximum
class PricingClassification
  def range
    return nil unless minimum?

They test Jumpstart's functionality. You're free to recreate them in rspec too.

If you want everything that's built with your favorite tools, Jumpstart Pro is not the template for you. Jumpstart Pro is built using everything that comes with Rails and as few dependencies as possible to keep it clean and organized.

Posted in Can Jumpstart initialize with RSpec instead of minitest?

You can add rspec. The template will come with minitest and you can choose to ignore or delete them. Makes no difference. 👍

Posted in Do I need the jumpstart gem embedded in my application?

You need to keep it. It manages the configuration. 👍

Posted in Reopen ActionCable after login?

Jumpstart modifies form submits to be AJAX requests using turbolinks_render.

Your default Rails form submission is a POST request, so the page would fully reload and ActionCable would connect.

I never thought about it, but that is probably something that can/should be triggered after login. A Stimulus controller for this would make sense. It can just check fi the connection is open and, if not, issue the connect. It would probably need to be on every page, unless there's a way to do it after login. I need to think on a good way to do that.

Like I mentioned before, CF is a proxy so it passes the requests to Rails. Rails serves up files just like it always does. Nothing special.

That's the cool part. When you configure the backend, it will accept all requests and then ask your app (the backend) for the files and send them back. It saves them in the CDN so that next request, it doesn't have to ask your app again and can serve it up immediately. It just sits in between the user and the app as a proxy.

Uploaded it to YouTube so you could see it early. 😎

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.