Activity
That's awesome. Curious to hear what change(s) made the biggest difference. That's a huge improvement.
Structured output makes advanced AI integrations actually possible. Imagine trying to parse a string response every time without structured json output! 😅
It's always trade-offs. For example, an icons gem is probably going to load them into memory so rendering icons is faster by not loading them from disk every time.
Reducing memory usage sometimes means making things slower so don't look at it as an arbitrary goal. You may want to keep it low so your server costs are low, but in production paying for more RAM to achieve more throughput is often worth the trade-off.
In general, I think a Rails app tends to use 400-600MB of RAM. Gems and different configurations can affect the usage so there's not really a specific number to aim for.
One thing you can do is enable jemalloc and that often reduces memory usage by a good percentage as it's more efficient than the default malloc.
https://community.render.com/t/how-to-use-jemalloc-in-ruby-web-service/1183
broadcasts_refreshes
actually broadcasts to a couple different streams:
<%= turbo_stream_from :lockouts %>
<%= turbo_stream_from @lockout %>
Yeah, behind the scenes you'd use ActionCable, but Turbo morphing is what will make that easy. You'll add "broadcasts_refreshes" to the models to have them broadcast a page refresh with those updates automatically anytime the database records change. We don't have a lesson on that just yet but I'll make one for you!
We'll definitely do a video on structured outputs. 👍
What other types of AI integrations would you like to see?
Posted in How to send Webhook?
Awesome! Sounds like a fun project. Definitely want to hear more about how it goes.
I remember now that I wanted to cover how to build this but also extract it into a gem so maybe we can kill two birds with one stone on this series. 🤔
Posted in How to send Webhook?
I don't think we ever made a lesson for this. I will prioritize that. 👍
I love removing dependencies. 💖
Also, learning how libraries can make features or dependencies optional is a great thing to learn along the way.
A couple things come to mind:
- Unless you have other things parsing the SQL, squishing it should be fine.
- You probably add to the payload instead of modifying it.
event.payload[:squished_sql] = event.payload[:sql].squish
I think Phlex or View Component is mostly personal preference. Phlex will be all Ruby and View Component can be a mix of Ruby classes, ERB, and sidecar Stimulus controllers contained in the same folder. Either way you go they're pretty similar.
Posted in Hash Fetch with Default Value Discussion
Guarantee you I've made this mistake many times over the years. 😅
Oh yeah?
Yep! The cool thing about Caddy is you can use it with anything, not just Rack apps.
I'm curious... if you've needed SSL for local development before, what were you building?
Feel free to change any of the fixtures as needed. The tests are there to make sure the built-in functionality works as expected, but you'll need to adjust them as you build out your application.
Agreed! The only thing that feels a little weird is the nested arrays, but it works so much better!
Hmm, yeah then you've already done that. Strange, I'm not entirely sure.