This Week In Rails: Ruby 2.4 Integer, Action Mailer rescued and more!

Shhh, stay quiet! Rails 5.0 lurks just around the corner and it’s a mean beast. 

Rails’ maintainers, computer scient(-ish)sts, spliced commit DNA merged long ago in hopes of creating a better web framework. The result is Jurrails Park. 

Here’s Kasper alongside self-volunteering co-editor Jeff Goldblum, saying: 

They were so preoccupied with whether or not they could, they didn’t stop to think if they should.

This Weeks Rails Contributors

Contributors! Contributors! Contributors!

62 commits and 22 people makes us a happy newsletter team ❤️

Fixnum + Bignum = Integer

The next version of Ruby, 2.4,  unifies Fixnum and Bignum into Integer. Have no fear, Rails is already ready with both forward compatibility, backward compatibility and all around compatible compatibility. Int’ no Fix’ too Big’, folks.

Action Mailer: rescue_from and more

Action Mailer can now rescue itself from exceptions with rescue_from

This lets the mailer handle errors from the delivering job when run with Active Job. 

Third, the exhaustively documented pull request changes how rescue_from handles Exception causes. Read more.

Fixed

Support nested calls to #suppress

Calling suppress within another suppression on the same class was previously a let down. 

Now the method doesn’t take its name too seriously and all should be good.

Improved

Relation blocked Enumerable count

One of the first Rails 5.1 features brings the framework appropriately forward. Literally by forwarding count on a Relation to Enumerable when passed a block.

Time#all_day meet Date#all_day

Rails has long had Time#all_day to really expand the horizon of past times. Now Date gets to go all_day too.

Though personally, dating for a whole day sounds pretty extreme, but kids these days ¯\_(ツ)_/¯

Wrapping Up

That concludes our report for this week. There were plenty of other things going on, so feel free to jump in and check them out yourself!

This Week In Rails 💯: RailsConf recap & Rails 5.0 RC 1 is out!

RailsConf 2016

Live from RailsConf, happy 100th newsletter from Godfrey, Claudio, Vipul, Roque and Prathamesh (plus Kasper and Jon joining remotely).

The train from Kansas City is leaving the station soon. Just in time for a quick recap of what happened at RailsConf 2016 and this week in Rails.

This Week’s Rails Contributors

This week 26 people contributed to Rails, including a first-time contributor. Thanks to your support, we are on our way to almost 5,000 all-time contributors!

Rails 5.0 RC “RaceCar” 1 is here!

Jeremy promised in his keynote that Rails 5 RC 1 will be released during the conference and it is here now!

Another key milestone towards the final Rails 5 release.

🚆 RailsConf 🚆

Keynote and lightning talks on YouTube

In the next weeks, Confreaks will be posting individual videos for each session. Meanwhile, you can still catch the full-day videos for Day 1, Day 2, and Day 3.

If you attended the RailsConf, don’t forget to let the organizers know your feedback before May 13th!

New Stuff

Allow accessing all helpers at the controller level

With this helper proxy, users can reuse helpers in the controller without having to include all the modules related to view context.

Add ActiveModel::RangeError

When provided with large numbers, Active Model now fails with a new ActiveModel::RangeError that makes it easier to rescue from, and inherits from RangeError to maintain backward compatibility.

Improved

Ensure compatibility between Rails Session and Rack Session

Rails session is now compatible with other Rack frameworks like Sinatra that are mounted in Rails. They can also use session tooling of Rails without any issues now.

Wrapping Up

Meeting you all at RailsConf was a lot of fun. And if you haven’t seen us up on stage during the lightning talks, here is the YouTube link of “Goodfry and his boy band”.

That concludes our report for this week. There were plenty of other things going on, so feel free to jump in and check them out yourself. Also look out for the announcement of all the videos from RailsConf on Confreaks!

See you next year at RailsConf 2017 in Phoenix AZ!

This Week In Rails: If You Read It Here, That Means It Happened

Kansas City 2016

Dear Mayor,

Welcome to Kansas City! This is your advisor Godfrey. Since you are new here, it must be a bit overwhelming for you. Don’t worry, I’m here to help you do your job. Let’s get to it!

1000 Commit Pile-Up Results In New Beta Release

Rails 5.0.0.beta4 was released this week. Based on the increasing version numbers, I speculate the core team is working towards a 5.0.0.RC1 release and eventually a 5.0.0 final release. I recommend you try out the beta release on our apps.

Rails Repository Receives New Commits

According to sources close to the development, 34 contributors were seen submitting patches to the Rails code base this week. From what I can tell, this appears to be a good sign.

RailsConf

Kansas Dresses Up In Color In Anticipation Of RailsConf

Our plans to import colors from Oz have worked – I am proud to say Kansas is no longer black and white. I recommend that you install the Guidebook app ahead of the conference. You might also want to sign up for the workshops too – see the official welcome email in your inbox for details.

Tapped Out: Local Breweries Close Doors

We are not interested in recycling the dishwater or taking 30-second showers. Worse than that, some of the sponsors have planned parties for the attendees. How can we call ourselves a decent city if we can’t accommodate that?

Put some drink in your think, Mayor, and get us some water.

Majority Of Rails Users Not Attending RailsConf, Poll Indicates

Despite already accommodating well over a thousand attendees, our polls have shown the majority of Rails users will not be able to attend the conference.

To prevent a public outcry, I advised the conference organizers to record all talks and make them available on this website after the conference.

They are planning to live stream the keynotes as well, although I heard the secret URL won’t be up until next Wednesday. I can hear the sound of F5 buttons cracking up from here.

New Stuff

Local Scientist Discovers New Methods To Manipulate Time

In a series of experiments to research Swearing as a response to pain, a local scientist has discovered some new methods to manipulate time by accident. As a result of this new discovery, these core extension methods will be available in Active Support 5.

Rails Users Add “Week” and “Hour” To Their Vocabulary

Also new to Active Support, Rails users will soon be able to express themselves in these newfound vocabularies.

Improved

Faster Code Found To Perform Better Under Load

A scientific study to end the decade-old debate in the programming community has concluded in a surprising twist. The report declared that faster code does seem to perform better, after all.

As a follow up to the research, this contributor was the first to apply the new optimization technique to Array#split. The work has resulted in some performance gains, contrary to everyone’s expectations.

Typos Hram Readablity According To Linguists

A group of linguists gathered in town to discuss the merits of semicolons. During a panel discussion, they have reached consensus that typos can indeed reduce readability.

Coincidentally, this week the Rails Guides have received a flurry of changes that improved their readability.

My recommendation? We should sit down and fix the typos in our city bylaws some day.

Fixed

ShareLock Fix Mistaken For Sherlock Holmes

It is well-known in the computer science community that concurrency is hard. This patch that just landed on Rails master is the perfect example to illustrate why – in an attempt to fix a bug in Active Support’s ShareLock class, the patch was briefly misidentified as Sherlock Holmes, causing a brief delay and a race condition.

Survey: Rails Users Find Double Loading Loading Unnecessary

Recently, an audit discovered that Rails sometimes loads the database schema twice. According to a survey, most Rails users do not find this necessary, leading to the “feature” being removed from master this week.

Not Fixed

JRuby Builds: “Too Flaky To Be Useful”

I have an unfortunate piece of news for you, Mayor. The JRuby builds have been temporarily flagged as allowed to fail on Rails’ CI servers. If you know anyone who works with JRuby, we could use some help identifying and fixing the root causes here.

Mystery

Regexp Experts Debates “Left To Right Or Right To Left; Is One Better?”

Despite promising results from last week, the researchers involved have backtracked their claims on the performance benefits associated with this change. Based on my negative lookahead, I believe this issue will remain a source of huge debate among the experts in the foreseeable future.

Wrapping Up

That concludes my report for this week. There were plenty of other things going on, so feel free to jump in and check them out yourself.

See you next week at RailsConf!

Rails 5.0.0.beta4

We’re happy to announce Rails 5 Beta 4 release. We’re down to 4 open issues on the issue tracker for Rails 5.0.0.RC1.

We continue to work torwards RC1. Between beta3 and beta4 Rails got over 1,000 commits!

To view the changes for each gem, please read the changelogs on GitHub:

This week in Rails: Speed improvements, database comments and more!

Hello everyone! Prathamesh here bringing you This Week in Rails. Let’s get started.

🏆 This week’s Rails Contributors 🏆

Thank you to 32 awesome people who contributed to Rails this week, including 5 first-timers! Want to join the party? Get started with the issues page.

🏇 String#blank? just became faster 🏇

This speed optimization will improve the performance of blank? calls against empty strings by about 3.5x. It was further improved to about 30% faster!! BOOM 💪

New Stuff

Ability to add database comments

It is possible to specify comments for tables, columns, and indexes in the database itself now with this addition. It currently works for MySQL and PostgreSQL adapters.

Improved

create_join_table works with non-integer column types

Creating a join table with create_join_table helper used to always create the columns with integer type. But now if you want to have uuid columns or any other type, it’s possible!

Fixed

Do not attempt to return connection with open transaction to pool

This fixed issues with intermittent test failures related to the Active Record connection pool trying to return connections at the wrong time.

Fix issues with inserting schema information on SQLite

Rails recently improved performance for inserting schema information using multi-row-insert. But some SQLite versions do not support the multi-row-insert feature which resulted into errors. Now Rails will gracefully handle this situation without an error.

Wrapping Up

That’s all for This Week in Rails. There were many more improvements than we have room to cover here, so don’t hesitate to jump in and check them out yourself!

See you next week!

🏄 This week in Rails 🏄: MariaDB, Action Cable, and more!

Hello everyone!

Jon here bringing you This Week in Rails from the sunny surf town of Biarritz, France 🇫🇷☀️

Ready to jump in and catch a few waves of updates?

Grab your surfboard and let’s go!

This Week’s Rails Contributors 🏆

Please share some aloha 🌸 for the 27 daring riders who contributed to Rails (and world happiness) this week, including 4 committers who caught their first wave 😍😎! You can, too! Check out the current issues if you’d like to paddle out, make new friends and join the fun 💙

MariaDB support comes to Rails 5! 🎉

Thanks to Jeremy Daer, Ryuta Kamizono, Vipul A M and Ian Gilfillan, Active Record is now fully compatible with MariaDB ❤️💛💚💜… click on our heroes’ names to open the commits and see what went down behind the scenes!

MariaDB is a community-developed open source fork of MySQL. Notable users include Wikipedia, Facebook, Google and, yes, Basecamp 3! Here is a good Wikipedia article about MariaDB and MySQL history. Game on!

🌊 Improved 🌊

Run Action Cable callbacks through the worker pool

Everybody out of the pool! 🏊 It was getting crowded in the water, but luckily our experienced Baywatch lifeguards Matthew, Sean and Jeremy 🏋 were on hand to, er, pool their efforts to ensure your database connections are managed automatically when Action Cable is involved! Synchronized water ballet, anyone?

Fewer string allocations in number helpers

No Strings are better than NoSQL, right? Ankit noticed that the number_to_delimited and number_to_rounded helper methods were creating duplicate strings. Check out the pull request to see how he improved it using derailed_benchmarks to check object allocations 🍰

Speed up and handle max_time edge cases

Rails has the need for speed 💨 and surfers Blake and Xavier managed a crowd-pleasing acceleration maneuver in AS::FileUpdateChecker using a single loop memoization rather than multiple loops, benchmarked using benchmark-ips. It’s good stuff; see the PR for more! 🍦

Speed up attribute_changed? in ActiveModel::Dirty

Faster than relocating to San Francisco ✈️ (and much more fun), sun-drenched rider Lihan was able to speed up attribute_changed? by setting the default options parameter to nil instead of a hash, and checking the result with benchmark-ips 😎

🌴 Fixed 🌴

Disallow #deliver_later after local message modifications

Lifeguard Jeremy came across a common, hard-to-detect 🐞 in the water: Local message changes weren’t being enqueued with the delivery job when using #deliver_later. This now raises a friendly exception to make sure your message modifications are made in either (a) the mailer method or (b) using a custom Active Job. Nice catch! 🌊

Revert Hash#transform_keys to always return a Hash

While surfing Mongoid’s test suite, an error alerted our champion Emily 🏄🏾 to a change of behavior in ActiveSupport#symbolize_keys: Rails 4.1 returned a Hash but 4.2/5.0 returned self.class. This launched an interesting discussion on the merits of expected behavior versus matching Ruby’s behavior. Have a look! 🍎

🌞 Wrapping Up 🌞

That’s all for This Week on the Beach with Rails™ 🌴. There were many more improvements (and great waves) than we have room to cover here, so don’t hesitate to jump in and check them out yourself… the water’s warm and the locals are friendly! 👣🐾

See you next week! 🍍🍌🍉🍇

This week in Rails: strong ETag validators, Action Cable enhancements and more!

Hello everyone! This is Roque bringing the latest news from Rails. Hope you enjoy, and see y’all at the RailsConf in a month!

This Week’s Rails Contributors

This week 39 people contributed to Rails. We also got 11 first time contributors. Welcome aboard folks and keep it going!

Strong ETag validators

Strong ETag is now available in addition to weak ETag. It implies that the response should be exactly the same and byte by byte identical. Useful when doing things like Range requests within a large video or PDF file.

Action Cable protocol negotiation

Action Cable will gracefully disconnect clients and disable the monitor if the protocol has changed. This allows clients to gradually move to the newest version.

Improved

Allow passing record being validated to error message generator

The record being validated is now accessible from the message proc to generate custom error messages like: proc { |record, data| "#{data[:attribute]} failed with value #{record.name}." }

Add non-US format support to number_to_phone

Need to format a non-US phone number? You can now use number_to_phone with the :pattern option as a Regexp.

Fixed

Fixed duplicated emails issue with Sendmail

There was an issue with Action Mailer when calling Sendmail with the -t argument. Sendmail would scan messages for recipients, and it could result in duplicated emails.

Fixed the String#to_time behaviour to match Ruby’s

Previously, the method returned today’s midnight time when there was no relevant information in the string. Now it returns nil.

Wrapping Up

That’s all for This week in Rails. As always, there are plenty of things we’re not able to cover here, so take a look at the changes yourself.

Until next time!

This week in Rails: new query methods, Action Cable enhancements and more!

####

Hey everybody! Tim here reporting from Portland, OR on another solid week for the Rails community. As a protest to April Fools’ typical tomfoolery, this edition is coming to you 100% jape-free. No, really!

This Week’s Rails Contributors

This week 29 lovely people contributed to Rails, including 5 for the first time! A big Friday Hug goes out to all of them! Feel free to check out the list of current issues for ideas if you’d like to join them ❤️

Improved

Active Record gets a few extra query methods

Ever find yourself writing cumbersome things like User.count.zero?? You can now use the terser User.none?, as well as User.one? and User.empty?, as these three methods just got added.

The default worker pool size for Action Cable just got lowered considerably!

The author of this revision put it best: “Whack it down from 100 to 4”. This will decrease the number of db connections for most, who probably don’t need so many.

Notifications can now hook into Action Cable

Just as you can subscribe to Action Controller’s #process_action, so you can now with ActionCable::Channel::Base#perform_action after this fine addition. Get notified!

Fixed

Prepared statements to have a cache separate from unprepared statements

This subtle bug was fixed this week, wherein a connection that was established with prepared statements enabled could fail if a query that had been previously run was run again with prepared statements disabled. This was because it was hitting the same cache as the prepared statements-enabled query. Prepared statements now have their own cache, which solves the problem. Hurrah!

rails runner now shows the correct command name when run with Spring

Running rails runner with no arguments or with the --help flag shows you some information on how to use the runner as a shebang line. Unfortunately, if you were using Spring, it would get the path wrong because Spring changes a variable that relates to the command that was run (bin/rails). That just got fixed in this revision!

Using rails restart with Puma now works!

Previously, when issuing rails restart with Puma running, it would fail to bring it up again since Puma was trying to inspect ARGV to decide how to go about it. The fix involved changing Puma to allow its configuration options to be overridden by Rails. Great job!

Wrapping Up

That’s all for This week in Rails. As always, there are plenty of things we’re not able to cover here, so take a look at the changes yourself.

Until next time!

This week in Rails: Cables, Mailers, Floats, and More!

Business Todd here with your weekly briefing of all the goings-on in the Rails organization.

Since our last update, a number of initiatives were undertaken by many of our stakeholders to breed cross-functional synergies between the underlying components of the Rails vertical. Or, if your eyes glazed over at the sight of “cross-functional synergies” or any of the other garbage I just typed out, a bunch of people did some stuff to make Rails better and junk.

yawn

I’m running this meeting and I’m already boring myself. Let’s just jump into it, shall we?

This Week’s Rails Contributors

28 beautiful humans helped make Rails better than it was last week. If you’d like to see your name on this list, check out the open issues.

Improved

Gracefully Handle Action Cable Client Disconnects

Formerly, Action Cable would raise a connection reset error if a client forcibly disconnected. This change avoids the exception by simply closing the connection if the client disappears.

Avoid Installing New Gems During the Upgrade Process

When running rails app:update, we should avoid adding dependencies on new gems. A previous change adds an option to dev environment config that would require the listen gem to be installed. Instead, the generator now adds the line in question as a comment.

Honor Default MySQL Modes

Active Record’s strict mode has traditionally overridden MySQL’s default modes. However, keeping these modes in place offers better compatibility with other databases. In Rails 5, Active Record will stop overwriting these defaults.

Improvements to Date Inclusion Validator

New in Ruby 2.2+, Range#cover? works with Date ranges. The date inclusion validator has been updated to allow Date ranges to use this method.

Float to Decimal Conversion Madness

To avoid rounding to incorrect values when coercing a Float to a Decimal, the scale needs to be applied before precision. Be sure to read the entire commit message for a summary of how the existing behavior may cause unexpected issues.

Fixed

Fix reset_session for API Controllers

request.reset_session relies on ActionDispatch::Flash, which is not included in API Controllers. This change moves that requirement to the Flash middleware itself.

Ensure Action Cable is Loaded in Application Generator

This PR fixes an issue where Action Cable would not be loaded properly if the app was generated without Active Record.

Generate ApplicationMailer for Engines

In a followup to one of the fixes from last week’s issue, we’re now ensuring that ApplicationMailer will be correctly generated in Engines.

Prevent Key from Being Created When Checking for Error Inclusion

Calling ActiveModel::Errors#include? with a key that didn’t exist would pollute the errors hash with they specified key and an empty Array as its value. This week, that behavior was corrected.

Wrapping Up

That’s all for This week in Rails. As always, there are plenty of things we’re not able to cover here, so take a look at the changes yourself.

Until next time!

This week in Rails: no-clash thread vars, a way to contribute and more!

Straight from the mail room, it’s this week in Rails!

We made sure to squeeze our lone chimp with a typewriter extremely talented editor Kasper for just a few more keystrokes this week.

The result is not a novel, but it’s pretty damn close to legible.

Let’s check it out!

This week’s Rails contributors

Did you know? Rails is written by people no smarter than you (I know, low bar! 😘). They show up, Google a few things for the common good and submit patches. They even get their name on this here fancy page!

A Rails conference in the Pacific

The pacific Rails conference is rolling, from May 20th to 21st in Taipei, Taiwan. Several editors of this newsletter will be speaking, so we recommend checking it out!

thread_mattr_accessor doesn’t clash with thread-locals

Rails 5’s thread_mattr_accessor wouldn’t expose a variable set at the class level to instances and vice versa, because it generated a key that wasn’t uniform both at the class and instance level. Now it does 😁

Improved

Once more, db:migrate creates the test database.

Rails considers the test database a part of the complete dev environment, as such running db:create in development creates the test database as well. You’ll be up, running, and testing in no time.

Document Rails’ logger + formatter interface

Rails’ logger and formatter — ActiveSupport::TaggedLogging — had a habit of saying, “tag, you’re it!”, when figuring out how to glue the pieces together. With new documentation, this rigamarole is easier to suss out.

Fixed

Break up an Action Pack and Action View circular require

Spinning assigns and assert_template out into its own gem exposed a circular require in Action View and Action Pack. Good news is, adding gem 'rails-controller-testing' to your Gemfile should be hassle-free after this (though if you’re using RSpec it needs a teensy bit more setup).

Generate ApplicationMailer if it’s missing

Rails 5 adds new application wide classes to inherit from, one being ApplicationMailer. New mailers automatically inherit from said class. However, the file for it wasn’t being generated if missing. Rest assured, it now is.

Call for contributors

Improve Rails’ multi database support

Want to give back to Rails, but don’t know where to start? Here’s something to do, straight from a Rails core member. Take a stab at improving multi database support with the suggestions at the link.

Could make a great Google Summer of Code project too 😉

Wrapping Up

That’s all for This week in Rails. As always, there are plenty of things we’re not able to cover here, so take a look at the changes yourself.

Until next time!