Chris Oliver

Joined

292,300 Experience
93 Lessons Completed
295 Questions Solved

Activity

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

If I'm looking for the template from a brand new Rails app, I'll actually open the github repo for Rails and find the template in there.

For example: https://github.com/rails/rails/blob/main/railties/lib/rails/generators/rails/app/templates/app/views/layouts/application.html.erb.tt

And I imagine you'd get answers quickest on StackOverflow. I always forget about the Rails discourse. I need to poke around on there more regularly.

Don't forget the GoRails slack if you're a subscriber! There's always people around to help there.

I spent a lot of time just reading source code for Rails and trying to apply those approaches to my own code.

Most of the deep knowledge is just Ruby, not Rails. I should mention, I made a course last year that digs into all these things that I wish I knew about Ruby when I was learning Rails. Explains a lot of approaches that you'll see in gems like Rails. Took me years to learn all this stuff, so I thought it'd be good to put it into a course. Might be worth checking out. https://courses.gorails.com/advanced-ruby-for-rails-devs

Posted in Multiple user types App design

Generally, the easiest is use 1 Devise model and separate models for the type of user. That way everyone uses the same sign in page.

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
end

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,

Time.zone 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: https://bugs.ruby-lang.org/issues/11473#note-53

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: https://www.mikeperham.com/2018/02/28/ruby-optimization-with-one-magic-comment/

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: https://github.com/tailwindlabs/tailwindcss-forms/issues/12

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. 👍