Rails 7.1 will give you a lot of possibilities: Active Record added an API for general async queries. Soon, you’ll be able to run aggregates and `find_by_sql` asynchronously. So you can do stuff like:
If you use Sidekiq directly in your Rails app, you have a `push_bulk` method to push gazillions of jobs to Redis to cut down on the Redis round-trip latency. Rails 7.1 brings this feature to Active Job through a new `perform_all_later` method.
Rails logs files are unchecked: they can grow to whatever size imaginable. Not anymore, there's a new config option in Rails to keep log files from taking over disk space!
You know those moments when you create a new app, only to realise you wanted to start with PostgreSQL but Rails by default gave you SQLite?
Here's a command to switch your database without having to touch a single file. Pass --force to skip prompts.
I'm available for work as a Ruby on Rails developer. I know Rails pretty well. CV upon request. Let me know if you or your team needs a hand.
RTs appreciated 😀
With more developers opting for SQLite on production servers, Rails is making incremental improvements to the SQLite3 Adapter. Find out more in this edition of This Week In Rails. 📰
Refinements in Ruby are powerful. Here's an example illustrating Ruby's dynamism. You can conditionally break out of a "refinement" with the `super` keyword. This means more control over when and how you want to manipulate core classes.
Did you know that in Ruby you can explicitly instruct a method not to take keyword arguments? Otherwise the method sucks up the keywords in the rest argument.
I'm working with the Rails Foundation to share Ruby on Rails tips with you officially. In a few days, you'll start getting weekly Rails tips on the Foundation's official X and LinkedIn accounts.
Follow Rails
@rails
here on X and also on LinkedIn.
Started a new Ruby and Rails podcast
@railschangelog
. I intend to publish weekly or biweekly.
Subs, RTs, and shares are appreciated! ❤️
I'm new to this, if you have ideas, suggestions or want to guest host, hit me up.
First episode coming next week.
Say you have a humongous app that could have several routes, some of which are unused but you have no quick way of checking which routes are unused--well, Rails has your back. You can now find and delete dead code around these unused routes and speed up boot time too. 🚀
Rails 7.1.0.beta1 is imminent. For a brief description of some notable features, I wrote 3 blog posts to give you an idea of the treats we'll be getting:
An Overview Of Ruby on Rails 7.1 Features. Part I
An Overview Of Ruby on Rails 7.1 Features. Part II
An Overview Of Ruby on
Some API access tokens are ephemeral, this means we need to keep track of when these tokens expire to invalidate a cache. Rails 7.1 makes this process a breeze. Here's how you can invalidate a cache and fetch a new token at the same time.
Is it just me, or have there been a resurgence of dormant Ruby/Rails meetups/conferences (like Tropical Ruby, RubyFuza, etc) in the past year or so, accompanied by the emergence of new ones? It's almost as if the Ruby community is experiencing a fresh wave of enthusiasm.
These two are equivalent but I've been doing the longer version only until recently. 🤦🏾♂️
BTW you'd think "rails r" would be short for "rails routes" -- it's short for "rails runner". Why?! When was the last time you did "rails runner"?
It's mind-boggling to think that in 2023 there are full-grown developers who'd rather spend hours bickering over tools. This is software craftsmanship, we pick and drop tools along the way.
It's not like you'll see two carpenters quibbling over what brand of nail to use to the
In Rails, you no longer need to call .new on a class with dom_id.
Allowing dom_id to accept a Ruby class instead of an instance streamlines its behaviour to match dom_class. This conserves memory as Ruby avoids creating a full object with all its associated callbacks.
In the last few months, I've seen an uptick in the number of Ruby content creators on Twitter, more people paying more attention to entry-level engineers, and extra efforts in making the Ruby community more open. These genuinely make me happy, and I hope it stays this way.
In this episode of the
@railschangelog
,
@dhh
and I got to discuss a lot. Among what we covered are:
Kamal
Rails 8
Authentication in Rails
The Rails Foundation &
#RailsWorld
On Writing Software Well
Delegated Types, and more!
Listen
If you're a Rubyist, did you know about the Ruby Association, and do you know there's an official certification for Ruby?
Taking these exams sounds fun, for me it's a way to support the association and I feel we should draw awareness to it.
The "Rails 7.1 Features" series has come to a close, showcasing numerous improvements and exciting features.
A sincere "thank you" to all the contributors that made this possible. The Rails community is incredibly grateful for your efforts. ❤️
When updating, deleting or reloading an Active Record object, Rails now allows you to specify columns you want to use in the generated SQL queries with query_constraints.
This augments Rails' support for composite primary keys and tenant-based sharding that requires all queries
#RailsWorld
was intense! Met many amazing people, learned a ton, and expressed gratitude in person to people whose gems or libraries I use. Thank you
@rails
, thank you
@AmandaBPerino
. Follow
@railschangelog
for updates...❤️
This week, Ruby on Rails saw 43 contributors, that's the highest I've seen! That's around 6 people per day having their code merged. Not only are more folks migrating to Rails this year, the framework itself is getting better... more fixes, enhancements, new features, etc. 🍻
Rails is getting a new test helper called `capture_emails`. This test helper is mostly to improve a common pattern we use in Rails with `assert_emails`.
I'm attempting video Ruby/Rails content creation. This thing is haaaaaard. 3 hours in and I haven't finished a 1-minute-long video. 😵💫 ... Hopefully, I can show you something in the next 48 hours. 😆
What really happens when you instantiate a class in Ruby? 3 things essentially. In this snippet we implement our own version of `new` to create a new instance of the `Country` class. All this freedom for free in Ruby.
If you're a Rails developer (new or experienced), I highly recommend you check out
@DriftingRuby
. Drifting Ruby is constantly producing high-quality content around Ruby and Rails that anyone can learn from! 🤌🏾
When you're upgrading your apps to Rails 7.1, you might notice a deprecation warning asking you to replace to_s methods with to_fs.
But why?
Ruby 3.1 optimised string interpolation for some objects unless to_s is overridden and Rails wants this optimisation for you too.
You use the `%i[]` syntax all the time to create an array of symbols, but what's the meaning of the 'i'? Where does it come from? The 'i' means "intern".
Just published the last episode of
@railschangelog
for 2023 with Xavier Noria.
Embarking on this podcasting venture has been a profoundly enlightening experience in ways I can't describe through text.
❤️ Thanks for being an integral part of this journey:
@AmandaBPerino
Just published a new issue of This Week In Rails focusing on the ongoing work on support for Composite Primary Keys.
The Asset Pipeline guides got a rewrite!
Reminding you that you can subscribe to get updates like this delivered to your inbox! 📥
This is the last issue of This Week In Rails for 2022. Don't forget to subscribe to get Rails updates in your inbox! Huge thanks to the team:
@GregMolnar
,
@morgoth85
and
@four54
. 🙏🏾
If you want to Rubocop only changed files, usually before a commit, here's an alias that works.
-> List modified files
-> Exclude deleted files
-> Grep *.rb files
-> Pipe to Rubocop for fixing
Working on something and learning more about Hotwire with Rails. I keep thinking... why do people complicate their lives with extra libs? The frontend solutions Rails provides are more than enough! 😳
A lot of the times when you use `source_location`, all you want is to see what a method is doing.. so you get a location, navigate to the file to inspect the method. Well, you can save those trips by using `source.display` to have a peek from your terminal.
Nerd BFCM stats:
Shopify’s egress processed 145 billion requests on Friday. App servers handled peak of ~60 million requests per minute. Increase of 38%. Total GMV was $4.1b, up by 22% from last year.
But Rails doesn't scale so what are we even doing 🤷♂️
Want to take a moment to publicly thank
@lucianghinda
. For some time now I've been observing Lucian and admire him a lot for:
1. his positive vibe and energy
2. consistent support to any Rubyist
3. encouraging Ruby content creation, etc
Thank you Lucian for your work in the
Building a Turbo Native app is new territory for most Rails devs. Strada coming out this year makes mobile hybrid applications even more interesting.
For
@railschangelog
, I'll sit and talk Turbo Native with
@joemasilotti
at
#RailsWorld
. Let me know if you've got questions about
Anytime I mention that I’m chuffed over the upcoming release of Rails 7.1 people ask why. In a 3-part blog series, I’ll show you why. I went through every single item of every single issue in 2022 of This Week In Rails. First blog post coming on Monday.
Rubocop will fix this for you, but it won't tell you why. Here's why:
"Subclassing an anonymous struct creates an extra anonymous class that will never be used."
-- Ruby Docs
I'll be interviewing DHH for the
@railschangelog
podcast. What would you like me to ask him for you? Maybe you have questions about Strada, Hotwire,
#RailsWorld
. Let me know! 🔴
Wrapping up the last in my "Rails 7.1 features series" and remembered Rails devs asking around "When will Rails 7.1 be released?". You don't have to wait, you have Rails 7.1.0.alpha that you can play with now.
This Week in Rails (the Rails newsletter), run by a small team of volunteers, is looking for a new logo we can print as stickers. We'd be grateful if you can or know any graphic designers who'd be willing to voluntarily create a slick logo for us.
RTs appreciated. ❤️
Just got home from
#RailsWorld
, I probably should write a blog post about my experience, I'll say more on
@railschangelog
for sure. But now I want to thank
@buzzsprout
for getting me there, and once again, thank you
@AmandaBPerino
, for everything! ❤️
In Ruby, there's `super`, quite common... but there's also `super_method`, that returns a `Method` of superclass which would be called when `super` is used or `nil` if there is no method on superclass.
Rails now allows you to tailor YAML serialization per attribute in Rails models. You can specify permitted classes and enable unsafe loads on a per-attribute basis for more flexibility.
Here's an example.
Some of you are not on Ruby 3.1, but when you get there, know that you can do this. I believe this was premised on the fact that often times you want to create a hash with values from variables of the same name as the keys. This syntax is shorter.