Ruby on Rails - May 2022
MAY, 2022

Ruby on Rails - May 2022

Hey folks - Updates for May 2022

Async aggregate & find_by queries

Active Record async support was limited to loading collections, but among the not-so-fast queries that would benefit from asynchronicity you often find aggregates as well as hand-crafted find_by_sql queries.

Ruby now supports the following methods as well (learn more)

async_coun
async_sum
async_minimum
async_maximum
async_average
async_pluck
async_pick
async_find_by_sql
async_count_by_sqlt

        

CSRF tokens can now be stored outside of the session

This is useful in cases where sessions are not stored in cookies. For example, when using a Redis session store, millions of sessions may be created for unauthenticated users where the session contains nothing but the CSRF token. In such cases, the cache may be thrashing, constantly evicting old sessions. This new configuration parameter will make it possible to store the CSRF token somewhere other than the session (i.e. in an encrypted cookie), making it possible for the session store to store only sessions for authenticated users.

Learn more.

Support encrypted attributes on columns with default values

Encrypted columns with default values are now automatically encrypted on object creation.

Before, it was failing to read these columns because their contents were not encrypted unless you enable


config.active_record.encryption.support_unencrypted_data
        

Now, it will encrypt those values at the record-creation time, learn more.

PRs on Rails repo won't be closed automatically


While the idea of cleaning up the the PRs list by nudging reviewers
with the stale message and closing PRs that didn't got a review in time
cloud work for the maintainers, in practice it discourages contributors
to submit contributions.
        

The autoclosing of PR has been stopped until the community comes up with a different solution.

Pattern Matching is not supported for ActiveModel

This provides the Ruby 2.7+ pattern matching interface for hash patterns, which allows the user to pattern match against anything that includes the ActiveModel::AttributeMethods module (e.g., ActiveRecord::Base). e.g.


case Current.user
in { superuser: true }
  "Thanks for logging in. You are a superuser."
in { admin: true, name: }
  "Thanks for logging in, admin #{name}!"
in { name: }
  "Welcome, #{name}!"
end
        

learn more.

Avoid query from calculations on contradictory relations

This PR avoids making a query to the database when the relation used for the count, sum, average, minimum, and maximum is a contradiction.

Previously calculations would make a query even when passed a contradiction, such as User.where(id: []).count. Rails no longer perform a query in that scenario.

learn more.

Added --name option to application generator

Now rails new generator supports --name option. Using this option will allow assigning a different name to the application than the folder name. i.e.


rails new my-app-folder --name=my-actual-app-name
        

learn more.

Ruby YJIT has been ported to Rust - Most likely coming with ruby 3.2.

Whats YJIT?

YJIT Tweet

The new Rust version of YJIT has reached parity with the C version, in that it passes all the CRuby tests, is able to run all of the YJIT benchmarks, and performs similarly to the C version (because it works the same way and largely generates the same machine code). They have even incorporated some design improvements, such as a more fine-grained constant invalidation mechanism which we expect will make a big difference in Ruby on Rails applications (learn more).

Ruby 3.1 Introduces Variable Width Allocation for Strings

This is some deep stuff you might not need to know or understand but it is very good to know that a lot of work is being done to make Ruby more efficient.

In short - Variable Width Allocation helps in reducing the bottlenecks and total memory usage while still maintaining similar?performance.

Want to know how? click here.

Security Updates, Improvements & more...

  1. Credentials leaking has been prevented by reducing the huge output when you call inspect on Rails::Appliccation class to just class name (learn more).
  2. Body content from redirect responses has been removed - Modern browsers don’t render the body content for redirects. The delivered bytes are therefore a small waste (learn more).
  3. Now you can implement a password challenge with the same ease as a password confirmation, re-using the same error handling logic in the view, and the controller by using has_secure_password (learn more).
  4. Now it’s possible to write video_tag(user.video_file) instead of video_tag(polymorphic_path(user.video_file)) (learn more).
  5. Now you can specify the maximum number of records destroyed in a single background job by the?dependent::destroy_async?association option. If the number of dependent records is greater than this configuration, the records will be destroyed in multiple background jobs (learn more).
  6. MySQL build rake task can now automatically use root user with no password when you create MySQL databases - this removes the tedious activity of creating the database user and granting privileges every time you need to set up Rails locally on a new computer (learn more).

And that's all for now, please subscribe to this newsletter to stay up to date with the latest stuff from the Ruby on Rails world.

This is Sajjad Umar (your own Desi Developer), Signing off...

Hassan Ahmed

Senior Software Engineer

2 å¹´

Great initiative!! Keep up the great work you have been doing!!

Abdul Wadood Aziz

Engineering Manager at IIFA TECH||Tech Enthusiast|| Helping Startups and Businesses For Growth And Development||

2 å¹´

You are doing Great work keep it up

Abdul Hanan

Full Stack Engineer | Node JS| REACT | ROR | Python | AWS

2 å¹´

informative

Abdul Hanan

Full Stack Engineer | Node JS| REACT | ROR | Python | AWS

2 å¹´

Appreciate it

要查看或添加评论,请登录

Sajjad Umar的更多文章

  • Ruby on Rails?—?March 2025

    Ruby on Rails?—?March 2025

    All the Rails News That Matters, Once a Month. Ramadan Kareem! ?? Wishing you all peace, blessings, and a month filled…

  • Ruby on Rails - Feb 2025

    Ruby on Rails - Feb 2025

    All the Rails News That Matters, Once a Month. Hey everyone—Sajjad Umar here with the February edition of Ruby on Rails…

  • Ruby on Rails — Jan 2025

    Ruby on Rails — Jan 2025

    All the Rails News That Matters, Once a Month. Happy New Year, everyone! ?? This is Sajjad Umar, kicking off 2025 with…

  • Ruby on Rails?—?Dec 2024

    Ruby on Rails?—?Dec 2024

    It's the only Ruby on Rails newsletter you will ever need! Hey guys?—?this is Sajjad Umar back with another edition of…

  • Ruby on Rails - Nov 2024 (Edition #35)

    Ruby on Rails - Nov 2024 (Edition #35)

    Welcome to the 35th Edition of Ruby on Rails Monthly - Sajjad here with some exciting updates from Ruby on Rails world.…

  • Ruby on Rails - Oct 2024

    Ruby on Rails - Oct 2024

    The only Ruby on Rails newsletter you will ever need! Hey Ruby folks?—?this is a fascinating month for the Ruby on…

    1 条评论
  • Ruby on Rails - September 2024

    Ruby on Rails - September 2024

    Welcome to the September 2024 edition of Ruby on Rails Monthly, this is Sajjad Umar your own Desi Developer. I have a…

    1 条评论
  • Ruby on Rails - Aug 2024

    Ruby on Rails - Aug 2024

    It's the only Ruby on Rails newsletter you will ever need! Rails 7.2 is out! There has been close to 2,500 commits made…

  • Ruby on Rails - July 2024

    Ruby on Rails - July 2024

    The only Ruby on Rails newsletter you will ever need! Welcome to the latest edition of the Ruby on Rails Monthly…

  • Ruby on Rails?—?June 2024

    Ruby on Rails?—?June 2024

    The only Ruby on Rails Newsletter you will ever need! Welcome to the latest edition of the Ruby on Rails Monthly…

社区洞察

其他会员也浏览了