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. πͺ
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!
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.
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!
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!
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.
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.
ππππ