Chris Oliver

Joined

291,230 Experience
86 Lessons Completed
296 Questions Solved

Activity

Posted in Rails Components From Scratch Discussion

These are my favorite kinds of things to learn and teach. Learning behind the scenes really helps you become a better developer. πŸ’ͺ

Posted in Better Debugging With The Ruby Debug Gem Discussion

That's a great tip!

VS Code also has an extension you can use https://github.com/ruby/vscode-rdbg

The other option is to replace foreman with overmind which allows you to do the same thing by opening another terminal and running overmind connect web to connect to the process. This will work with binding.irb, pry & debug or anything else.

Here's my bin/dev

#!/usr/bin/env sh

PORT="${PORT:-3000}"
export PORT

if command -v overmind > /dev/null 2>&1; then
  exec overmind start -f Procfile.dev "$@"
else
  exec foreman start -f Procfile.dev "$@"
fi

Posted in Rails Components From Scratch Discussion

Glad you found it helpful!

Posted in Rails Components From Scratch Discussion

The refactoring part is half the fun. πŸ˜„

Thanks Kylo Ren!

Posted in Rails & Vue.js Trello Clone - Part 1 Discussion

Yeah, thankfully webpacker is no longer the way to go. Unfortunately Rails didn't pick just one option to replace it, they left it open ended.

Personally, I use esbuild with https://github.com/rails/jsbundling-rails.

Posted in Routing Concerns and Scopes in Rails Discussion

Interesting. I don't think I've seen this documented anywhere. It seems like it would filter out the only: and other options and the leftover ones are set as defaults?

I know you can do this:

resources :todos do
  scope defaults: { record_type: "Todo" } do
    concerns :likeable
  end
end

Just recorded a Routing Concerns in Rails screencast using routing concerns to refactor this further.

I didn't even realize there were routing concerns. TIL! And yes, they sure can. 😲

Much cleaner to read and I don't think people (like myself) use these helpers enough!

Posted in Liking Posts in Rails with Hotwire Discussion

Really fun to revise our most popular GoRails episode on Liking Posts and update it for modern Rails. No more jQuery, js.erb responses, or any custom JavaScript! Just super clean and simple operations with Hotwire.

Posted in Understand Scope Returns Discussion

Excellent episode Collin!

Another tip is you could keep the future_events scope returning a Relation. And possibly break the sorting out in case it’s used for other queries as your application grows.

class Event < ApplicationRecord
  scope :future_events, -> { where("start_time > ?", Time.current) }
  scope :newest_first, -> { order(start_time: :asc) }

  def self.first_future_event
    future_events.newest_first.first
  end
end

You're welcome and thanks for watching Terry!

Posted in Authenticating Blog Admin Pages Discussion

You're fine! And no, you shouldn't put your real password in there if it's public.

If you want to make it interactive, you can use gets to ask the user for their password when the seeds script runs so there are no passwords hardcoded in the file.

Posted in Authenticating Blog Admin Pages Discussion

It is used once to create your account. Only you can run it. It is perfectly safe. You will change your password after logging in so it isn't the default.

You can use host! "subdomain.example.org" to change the host for a test. πŸ‘

Posted in Adding a New Blog Post Action Discussion

We're not overriding it. Rails is only going to call one method in the controller when an HTTP request comes in. We're just using the same variable name because that's the object were working with.

It usually takes a couple months for them to edit all the videos and publish them to YouTube. Follow the Railsconf twitter account and I'm sure they will tweet when they're live.

Yes, it supports all Ruby versions because it uses ruby-build underneath.

Posted in Testing API Integrations with WebMock Discussion

πŸ’–πŸ’–πŸ’–πŸ’–