Chris Oliver


274,550 Experience
31 Lessons Completed
298 Questions Solved


Posted in Rails latest (6.1.1) with Ruby latest (3.0.0)

What glitches are you referring to?

Ruby 2.7 and Rails 6.1 are probably the best to go with for now I'd say.

Posted in Go Rails Youtube videos not loading

Strange, the Message Templates video plays fine for me, logged in and incognito. Maybe a browser extension or something blocking it?

Side note, the search is SLOW. I need to fix that.

You can't use include with a class. Remove that and reference the class directly like so:

class Licencia < ApplicationRecord
  validates_with Validators::LapseValidator

That should do the trick. 👍

It needs to be namespaced under Validators:

class Validators::LapseValidator < ActiveModel::Validator

Posted in Where do I put a custom validator for a model?

Generally, the concerns folder is for modules so it might get confusing in there but it should work.

You could also probably use app/models/validators/my_validator and include Validators::MyValidator now that I think about it.

I like this better than app/validators

Posted in Where do I put a custom validator for a model?

Any folders in app/ will be autoloaded, so you could create app/validators/my_validator.rb and include MyValidator in your model. Rails will autoload that and find it correctly. This is my preferred way of doing things usually.

Or you could put it in lib and require it as well.

Posted in What is Hotwire Strada?

No idea either! DHH said something that you can do 95% of mobile with Turbo and no Strada. Doesn't really explain much, but I'm real curious when it ships!

Posted in Action Mailbox Routes

Add a constraint to your catch-all to ignore the /rails routes. 👍

Posted in Authentication in 2021

I think it's mostly because leaving your user accounts in the hands of a third-party adds a lot of complexity and they'd rather have full control in-app.

Those options can be good options if you need enterprise integrations or you're building static apps though where you don't have a backend that can do it.

Posted in Pair Programming on Rails Scopes Discussion

Hey Charles, comes from ActiveSupport, so you'll need to either do this in the Rails console or require "active_support/all" in your IRB session.

This never became the default in Ruby 3 unfortunately. See:

I don't use it, but I probably should although I'm sure I modify strings like this more often than I realize. It's a pretty great performance improvement when you can use it!

Some more good reading:

Check the readme, we have instructions for that. 👍

Posted in How to use Action Mailbox in Rails 6 Discussion

You create a password in the credentials (make one up) and then use that password in Sendgrid's webhook URL. That way Rails can verify the POST request came from Sendgrid (and not someone trying to abuse your app).

Posted in Login with Facebook Discussion

Try using ngrok to expose your localhost to the internet. That will give you a public domain and SSL.

Posted in error with purgecss and Tailwind 2

You're welcome and thanks for all the support! 🙏❤️

I think we didn't have the issue with Jumpstart Pro because I have some examples in the docs or something, so ours didn't get purged.

Posted in error with purgecss and Tailwind 2

There's some discussion about this on the GitHub repo:

Use a before_action in ApplicationController to check if the user is signed in and has an incomplete profile. Then redirect them to the page for doing that. 👍

Posted in Remote form - update partial in Rails 6

Hey Tim!

This actually might change very soon whenever the "New Magic" DHH keeps talking about gets released.

There are a few good options currently that I like using:

  1. Write a Stimulus JS controller that makes that AJAX request and replaces the partial in the DOM. Rails just needs to render the partial and return that without the layout.

  2. For realtime, you can use CableReady to broadcast the partial from the backend to the frontend with ActionCable. The partial would just need an ID so that it can be searched for and replaced.

Posted in Database structure advice

Hey Amanda!

That is a fun challenge to solve. I wouldn't add that many columns to the table as that would get real tricky to manage. I like the idea of doing a new table, that could work well.

The two options I would consider:

  1. Use a json column and the store_accessor functionality in Rails to store these values in a json field.
  2. Separate table with name and value:integer

Both of these options would let you freely add/remove values as needed. And you can leave the values as nil by default so they don't take up any space if they're not being used.

There aren't too many pros/cons to these. The separate table would just require a join but you can query against json columns in postgres and mysql too so they're similarly equal. I guess if you needed to add any Ruby logic to a value, the separate model would be helpful in that case.

Posted in Please help!!! My App is Down

Hey Houssein,

You should contact support in Hatchbox, not on the GoRails forums. 👍

logo Created with Sketch.

Screencast tutorials to help you learn Ruby on Rails, Javascript, Hotwire, Turbo, Stimulus.js, PostgreSQL, MySQL, Ubuntu, and more. Icons by Icons8

© 2022 GoRails, LLC. All rights reserved.