Ruby on Rails - February 2024
Sajjad Umar
Senior Backend Engineer | Ruby on Rails | Author of Ruby on Rails for Agile Web Development | Manager RubyConfPk | Desi Developer | Building adex.world
Greetings,
As we dive into the February edition of the "Ruby on Rails, Monthly" newsletter for 2024, let's infuse our coding journey with a touch of warmth and affection. I hope this month brings you renewed inspiration and a deep appreciation for the craft of Rails development. I'm Sajjad Umar, your DesiDeveloper, and I'm thrilled to continue exploring the ever-evolving world of Ruby on Rails with you. Let's embark on this month's adventure with passion and excitement!
CFP For RailsWorld Are Now Open
Today Rails is stronger than ever thanks to continued progress in both core frameworks, like Active Record and Action Mailbox, as well as associated tools and frameworks, like Hotwire, Kredis, and Propshaft.
This time we will especially be on the lookout for original talks that fall into a few specific themes:
Talks submitted should be max 30 minutes long, and there is space for 24 talks in the agenda, including 4 invited keynote spots.
The call closes at 11:59 PM on 21 Mar 2024
Read all the details here.
Rails Documentation Improvement has Begun
Acknowledging the already impressive state of the documentation, the foundation aims to review, update, and enhance it further. The process involves an audit of the documentation, followed by writing, team review, PR creation for community input, and eventual merging. The community is invited to participate by reviewing PRs labeled 'RF-DOCS' and 'rails foundation', providing technical feedback, and opening issues labeled 'docs' for areas needing improvement. Existing contributors are encouraged to continue their contributions, as the project complements rather than interrupts ongoing documentation efforts.
Read about the entire process here.
Read all about the changes made so far here.
Resolved Missing IPAddr Prefix in Msgpack Cache Serialization
This Pull Request has been created because we noticed the msgpack serializer missing the prefix(netmask) data of the IPAddr object when dumped.
This PR fixes the issue.
Read all the details here.
Rails Default Load Paths Now Limited to Directories
Files such as app/README.md should not be in the autoload paths. This PR removes files from the default load paths set up by the Rails framework.
Although File.stub(:exist?, true) in the existing test has been changed to File.stub(:directory?, true), it is obvious that this does not break the objectives of the test.
Read all the details here.
Implemented Customized Prompt for Rails Console
The rails console's prompt is not easily distinguishable from the normal IRB console. It also doesn't provide Rails-specific information to assist developers.
There were 2 more follow-up PRs on this:
The combination of red and blue is more color-blind friendly than red and green. And Instead of displaying [env]:[line-number]> as the prompt, showing [app-name]([env])> provides more value to the user.
For example, if the app's top-level module is MyApp, its development prompt would be:
my-app(dev)>
After making all the changes the console now looks like this:
Read all the details here.
schema_dump, query_cache, replica and database_tasks are now configurable via DATABASE_URL
In database.yml, schema_dump can currently be set to false, nil or a file path.
If you configure your database via DATABASE_URL, the false value does not work because it comes through as a string.
This PR fixes this and all other boolean configs, not just schema_cache.
Read all the details here.
Fixed rotation detection for HDR videos
The video analyzer relied on the positional reference of side_data to fetch the rotation metadata. However, the side_data is not guaranteed to be in the same position for all videos. For instance, HDR videos shot on iOS in portrait mode have "DOVI configuration record" side_data in the first position, followed by the "Display matrix" side data containing the rotation value.
This fix removes the positional reference and explicitly searches for the "Display Matrix" side_data to retrieve the rotation angle.
Read all the details here.
Consistent ArgumentError for Invalid Nested Attributes Arguments
This PR Updates ActiveRecord::NestedAttributes#assign_nested_attributes_for_one_to_one_association to raise an ArgumentError when given an invalid attributes argument similar to ActiveRecord::NestedAttributes#assign_nested_attributes_for_collection_association.
Also makes a slight improvement to the existing error for collection associations.
Read all the details here.
领英推荐
ActiveRecord::DelegatedType changes
While dealing with strong parameters in API requests and validating the polymorphic type field for a delegated type in a slightly abstract manner, it is useful to have access to the allowed types.
This Pull Request changes the methods defined by ActiveRecord::DelegatedType
Read all the details here.
Deprecated passing nil as model arg instead of raising ArgumentError
This Pull Request removes the changes introduced in (Handle nil form_with model argument #49943) since these changes are breaking changes. Instead, we will first deprecate the current default value of the model: argument in form_with.
Read all the details here.
Skiped CSS when creating APIs
This Pull Request has been created because Tailwind CSS was included when generating APIs. This Pull Request changes the behavior of skipping CSS for APIs.
Read all the details here.
Commented-out lines in .railsrc file should not be treated as arguments
This Pull Request changes Railtie ARGVScrubber to ignore text after # symbols.
Read all the details here.
Added row_count field to sql.active_record notification
This Pull Request modifies *Adapter.log, which emits sql.active_record notifications. Previously, the instrument call only logged information within a request but allowed modification of the payload by the caller within the block. The change adds a new field to each sql.active_record notification, indicating the number of result rows returned in each query. This enhancement enables consumers of the notification to utilize this metric. The PR also includes three tests in the instrumentation test suite to verify functionality for various types of queries.
Read all the details here.
Allowed encryption without compression
Added a compress option to ActiveRecord::Encryption::Encryptor, which defaults to true. When set to false, the encryptor will never compress the data.
This can be used with the encryptor option in the model:
class Record < ApplicationRecord
encrypts :field, encryptor: ActiveRecord::Encryption::Encryptor.new(compress: false)
end
Read all the details here.
Properly synchronized Mysql2Adapter#active? and TrilogyAdapter#active?
Connections must not be shared between threads but it is required when running transactional tests or system tests and could lead to a SEGV.
This PR properly synchronizes Mysql2Adapter#active? and TrilogyAdapter#active? As well as disconnect! and verify!.
Read all the details here.
Fixed JSON-encoding ActiveStorage::Filename
ActiveStorage::Filename was missing quotes when encoded, generating invalid JSON like this:
JSON.generate(foo: ActiveStorage::Filename.new("bar.pdf") # => '{"foo":bar.pdf}'
This PR Delete to_json and rely on the implementation from ActiveSupport::ToJsonWithActiveSupportEncoder.
Read all the details here.
Enhanced Query Log Tags with :source_location Option
This PR adds support for showing where a query is defined in the Rails logs when using Active Record Query Logs.
Read all the details here.
Optimized Memory Allocation with Default Dockerfile Setup of jemalloc
Ruby's use of malloc can create memory fragmentation problems, especially when using multiple threads like Puma does. Switching to an allocator that uses different patterns to avoid fragmentation can decrease memory usage by a substantial margin.
Read all the details here.
Implemented Rails::TestUnitReporter#prerecord
Minitest's pre-test invocation enables printing the test name beforehand, aiding in debugging slow or stuck tests, particularly in verbose mode. This feature helps identify stuck tests before deadlock occurs, eliminating the need for cumbersome workarounds to pinpoint the problematic test. Additionally, this mechanism aligns with the default behavior of Minitest's reporter in verbose mode.
Read all the details here.
Desi Developer
Really exciting update, I have completed 9 chapters of my book “Ruby on Rails for Web Development“. 3 more to go, the goal is to publish it around the end of March 2024!
That is it for this month’s edition of Ruby on Rails monthly. As I conclude this February edition of the "Ruby on Rails, Monthly" newsletter, I want to extend my sincere gratitude for your continued support and engagement. Your enthusiasm fuels my passion for Rails development, and I'm truly grateful for the opportunity to be part of this vibrant community. As I strive to bring you even more valuable content and insights in the coming months, I kindly invite you to consider upgrading to a paid subscription on Substack to support the growth of this free newsletter. Your contributions help me maintain the quality and frequency of our updates, ensuring that I can continue delivering top-notch content to you and fellow Rails enthusiasts. Thank you for being part of this journey, and here's to many more exciting discoveries in the world of Ruby on Rails!
Subscribe now
Until we meet again ??
If you are a paid subscriber already thank you for making this newsletter sustainable and helping out the community.
Backend Developer | .NET Web API | Software Engineer
1 年Syed M. Sawaid