[ANN] Rails 5.0.1.rc1 has been released!

Hi everyone,

I am happy to announce that Rails 5.0.1.rc1 has been released.

If no regressions are found, expect the final release on Tuesday, December 6, 2016. If you find one, please open an issue on GitHub and mention me (@matthewd) on it, so that we can fix it before the final release.

CHANGES since 5.0.0

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

Full listing

To see the full list of changes, check out all the commits on GitHub.

SHA-1

If you’d like to verify that your gem is the same as the one I’ve uploaded, please use these SHA-1 hashes.

Here are the checksums for 5.0.1.rc1:

$ shasum *-5.0.1.rc1.gem
f912b040b65f335c93ae888eb3317a8b161abbb1  actioncable-5.0.1.rc1.gem
2f6190125148b61871fd01323798cfbfbf267723  actionmailer-5.0.1.rc1.gem
161e6e15206028d76c8f2d4822c8783f16ac46ec  actionpack-5.0.1.rc1.gem
09f86171dfdb6d60146b3028cd71b5760e8c2432  actionview-5.0.1.rc1.gem
8506ea383e722304614f89e3757bf2546d5c6d8f  activejob-5.0.1.rc1.gem
25c3f96faee14dcbc3d91a465ad6b3866fd19cfb  activemodel-5.0.1.rc1.gem
2e01ee70c2e3b49885ae9b1a845d33327c7010e8  activerecord-5.0.1.rc1.gem
02412998c47a1ca8d1b7459976b98414aa535916  activesupport-5.0.1.rc1.gem
cae7d263e8128fab14b72d32ad6e82e436fd58bc  rails-5.0.1.rc1.gem
5193a647536cd700b13c18e6de6a4382ead7c6e0  railties-5.0.1.rc1.gem

As always, huge thanks to the many contributors who helped with this release.

This Week in Rails: Active Support deprecations and more!

Hello everyone!

Tim here bringing you all the latest from This Week in Rails…..

This Week’s Rails Contributors

This week 29 lovely people contributed to Rails, including an incredible 9 for the time! Why not put yourself in the next installment of This Week in Rails by tackling one of the open issues out there?

Improved

Remove Active Support deprecations

In preparation for the 5.1 release, methods marked as deprecated in 5.0 are being removed. If you’ve been seeing any of these warnings, you need to get on ‘em now! Notably, this PR waves goodbye to ‘alias_method_chain’ , which was made obsolete by Ruby 2.0+’s ‘Module#prepend’

Fixed

Support AC::Parameters for PG HStore

As of Rails 5, Active Record determines that a value needs to be serialized if it is a ‘Hash’ object. If passed an ‘ActionController::Parameters’ object instead (which no longer inherits from ‘Hash’ ), serialization would break. This change restores the original behavior.

Fix JSON encoding of “Infinity” and “NaN” values

If ‘as_json’ returns “Infinity” or “NaN” for any value, it causes ‘JSON.generate’ to 💥 because these values are not allowed in JSON. Instead of being treated as primitives, ‘as_json’ is called on these values recursively, so that they are properly serialized as “null”. Phew!

Fix incorrect output from rails routes when using singular resources

‘rails routes’ was showing some incorrect output if you had singular resources defined. Specifically, routes for the # ‘show’ action would appear under the “edit” helper, which is clearly wrong. Thanks to the rjigging of the order in which they appear in this PR, your routes should now be correct!

Correctly count new records when calling uniq on associations

If ‘CollectionProxy’ has more than one new record, a call to ‘uniq’ would yield the wrong result. This was because this method was aliased to ‘distinct’ , which is really a different concept. The original behavior was restored thanks to this reversion.

Wrapping up

That’s it from This Week in Rails! There were many other great contributions, too numerous to list here, but feel free to check them out!

Until next week!

This Week in Rails: connection statistics, query caching fixes and more!

Hello everyone!

And welcome to our special edition from, live from RubyConf in Cincinnati 😎.

This is Vipul along with Tim and Prathamesh teaming together to bring you all the latest news from the Rails community.  Lets get started!

Rails Contributors

This week 20 people contributed to Rails. We also got 3 first time contributors. Thanks all for your amazing contributions ❤️

If you too are looking to help out, head over to our issues.

Improved

Active Record connection pool adds a stat method

ActiveRecord::Base.connection_pool now has a stat method that returns statistics about the current status of a connection pool. For Example:

>> ActiveRecord::Base.connection_pool.stat
=> { max: 25, total: 1, busy: 1, dead: 0, idle: 0, num_waiting: 0, checkout_timeout: 5 }

Avoid unscope(:order) when limit is passed for a count query

If a limit is passed, record fetching order is very important for performance.

This fix makes changes so that we don’t unscope and remove the order from a count query when a limit clause is passed to it.

JRuby dependencies are now resolved for the latest version

As part of the ongoing effort of making Rails 5 compatible with JRuby, the test suite got updates for the JRuby version it runs on, to make it satisfy the dependencies required for the tests.

Fixed

Clear query cache during checkin, instead of an execution callback

Previously ActiveRecord::QueryCache using the new Rails executor may result in dirty query caches across threads. 

Releasing a connection in one thread may return it to the pool with cache still enabled and dirty, and the executor lost track of the connection so it may clear another, and another thread may pick up the dirty cache and never turn it off.

This fix makes changes so that query cache does not persist while a connection moves through the pool and is assigned to a new thread.

Configure query caching (per thread) on the connection pool

If the result of ActiveRecord::Base.connection is different across different threads, enabling the query cache in one thread will have been leaked, which could change the state of another.

This addresses the issue by making query caching local to the current thread.

One More Thing ™

Bona fide system testing in Rails 5.1

From DHH on Twitter:

The work being done is soon to be bundled into a new gem inside of Rails, that will hopefully be part of Rails 5.1!

Wrapping up

That’s it from This Week in Rails! There were many other great contributions, too numerous to list here, but feel free to check them out!

Until next week!

This Week in Rails: better Active Record methods and more!

Hello everyone! This is Roque bringing latest news from the Rails community. Stay tuned!

This Week’s Rails Contributors

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

Improved

Deprecate the behavior of ActiveRecord::Dirty in callbacks

The behavior of Dirty methods inside of after_(create|update|save) callbacks will be changing in the next version of Rails. Click here to check out the API details.

Allow Active Record slice to take an array of methods

No more having to expand an array with * when passing it to the slice method of a model. Something like user.slice(keys) will Just Work™.

Fixed

Fix the issue with duration of time varying for DST changes

Previously, ActiveSupport::Duration.parse would try to be consistent across DST boundaries, and either the duration would be shorter or longer depending on the time of year. Now it uses an absolute reference point in UTC that is not subject to DST transitions.

Remove Active Record tasks from bin scripts if it is skipped

bin/setup and bin/update will no longer include db:setup and db:migrate if Active Record is skipped in the application.

Wrapping up

That’s it from This Week in Rails! There were many other great contributions, too numerous to list here, but feel free to check them out!

Until next week!

👻 🎃 This Week in Rails: Scary Monsters and Nice CSS Sprites!

Boo! Hey ghouls and goblins, Andy here. This is going to be loaded with groan-inducing Halloween-themed puns. If you weren’t turned off already by the Skrillex reference, please keep reading!

Let’s take a look at 👻 Frankenstein fixes, 💀 dead code, and 👿  devilishly-detailed documentation changes…carved out this week! 🎃

Ruby on Rails Pumpkin, carved by Jack, Graham, Zachary and Matt at Shopify.

Rails Contributors

We had 22 Ruby on Rails contributors this week, including a first-time contributor. Thanks!

Improved

Permit loads while queries are running

A query may wait on a database-level lock, which could lead to a deadlock between threads. No one likes deadlocks. They are the stuff of developers’ nightmares! 💀

Remove unnecessary respond_to?(:indexes) checks

All database adapters have implemented the indexes method and support was removed. Some concerns were raised (from the dead? 💀), but the contributor demonstrated the requirement for database adapters to support indexes in early versions.

Fixed

Clear the correct query cache

The correct query cache was not being cleared. The author mentioned that this bug was happening in Sidekiq as well. Check out the details!

Fix HABTM associations

Use constants, strings, and symbols to express your HABTM associations. Check out the commit for more details.

Wrapping up

That’s it for this week. Check out all the changes here. May your bucket (or the buckets of your children) be filled with sweet Halloween treats! 🍬

This Week in Rails: greener JRuby, optimistier locking and more!

Hey peeps, Kasper here.

It’s that time of the week again, when that newsletter you read while frantically checking http://downforeveryoneorjustme.com is here.

Oh, you think we’re down, cupcake? I’m afraid that’s just you buddy, we’re fired up and ready to go!

This weeks Contributors

Did you know you can contribute to Rails? Oh, I’m not kidding! It’s totally open source and everything.

In fact check the next item if you’re looking to join the list, codeslinger!

JRuby turns Rails green with envy

Before RubyConf the JRuby team would like to get the whole Rails test suite passing and green.

Already some fixes have been committed. Check out the linked tweet and see if there’s something you can help with.

Improved

Optimistic locking unlocks overriding

If you’d been a good sport and optimistically tried to set the lock column value, you’d be sorry. Now you would be happy because it’s fixed!

Allow any key in Renderer environment hash

Since Rails 5 you’ve been able to render templates outside of your controller actions. Now you can pass in arbitrary keys when performing that kind of rendering.

Publicize process in controller tests

In your ActionDispatch::IntegrationTest controller tests you can use the get etc. request shorthands which would just pipe through to a private process method.

Now that method is public so you can better see the documentation on it.

Fixed

Prevent test framework from loading in production

Some dingus accidentally caused minitest to be loaded in the production environment.

Luckily that’s fixed now!

Wrapping up

That’s it for this week, as usual there were more changes than what we can fit, feel free to check them yourself here. Until next week!

This Week in Rails: onward, we go!

Happy Friday from sunny Los Angeles!

Claudio here with the latest news from the rails/rails repository. Here’s a recap of the commits and pull requests merged into master this week.

This week’s Rails contributors

14 programmers contributed to Rails this week, two of the them for the first time. If you haven’t contributed yet, I hope you will join the list next week.

Improved

ActionCable now permits same-origin connections by default

Same-origin connections are now permitted by default. If you want to stick with the old behavior, you can set config.action_cable.allow_same_origin_as_host = false 

explain why autosave= disables inverse_of

autosave and inverse_of do not get along together, since they may for example cause double saves.

Fixed

Work around read/close race

If one thread calls close on an IO at the same time that another calls read, segfaults might have occurred. This has now been fixed!

Gone

Fixnum and Bignum are deprecated in Ruby trunk

A small upgrade to the Rails codebase to have it ready for the upcoming release of Ruby 2.4 which has deprecated Fixnum and Bignum.

Remove deprecations in Active Model, Action View and Active Job

And in Action Pack too. Methods that were deprecated in Rails 5.0 will be gone once Rails 5.1 ships.

Wrapping up

That’s it for this week, as usual there were more changes than what we can fit, feel free to check them yourself here. Until next week!

This Week in Rails: Getting Ready For Ruby 2.4

You are reading This Week In Rails!

This week’s Rails contributors

The content for this week’s newsletter is sponsored by the 19 individuals who authored them!

Fixnum and Bignum are deprecated in Ruby 2.4

One of the notable changes in the upcoming Ruby 2.4 release is the unification of Fixnum and Bignum into a single Integer class. Following that change, the legacy classes were deprecated recently.

This pull request avoids triggering those deprecation warnings with a feature detection. If you maintain code that references those constants, you might want to adopt this pattern in your projects too!

Remove json gem dependency

Related to the unification of the integer classes: native extensions that references the rb_cFixum and rb_cBignum C constants need to be updated as well.

The popular json gem is one of those native extensions. Fortunately, all modern versions of Ruby bundles the json library. If your are targeting Ruby 1.9 and above, you could simply remove the json gem as a dependency.

Improved

Avoid bumping the class serial

Back in May, a regression was reported that Rails 5 invalidated Ruby’s class_serial on each request. This internal counter is used to invalidate the class-level method caches.

The issue was tracked down to the use of instance_exec. While there is hope that this restriction could be relaxed inside Ruby itself, this patch at least temporarily fixes the problem on Rails’ side.

Speed up Time.zone.now

Once upon a time, Time.zone.now could be quite a bit slower than the stock Time.now (allegedly up to 25 times slower). This pull request significantly closes the gap.

Fixed

Avoid compiling ruby keywords into template locals

Have you tried rendering a partial while injecting local variables called “class” or “module”? It wouldn’t work, and it will give you a pretty bizarre error.

This pull requests avoids the error by skipping over invalid local variable names, while still allowing them to be accessed via local_assigns.

You can read more about this issue, as well as the story behind this pull request in Peter’s blog post.

Gone

Remove undocumented Action Cable “faye mode”

Did you know that there was an undocumented “faye mode” for Action Cable?

No? Good. Because it’s now gone!

Wrapping up

That’s it for this week, as usual there were more changes than what we can fit, feel free to check them yourself here!

Until next week!

This Week in Rails: cable got buffer, callbacks stripped, and more!

Cadet, you’re at the new frontier! Orbiting the red planet just yonder, you ponder and wonder:

Do Martians drink their Martinis on the rocks?

All this crew member knows is that he prefers his scoops on the Rails — good news, everyone: We’re setting course for such a delivery!

This Week’s Multiplanetary Contributors

22 contribunauts came aboard the contributor list this week with their precious commits harvested for the good of all. You’ve earned this heart of gold: 💛

Action Cable buffers socket writes

Quoting the description:

Sockets can sometimes block, leading to reduced system throughput as threads get tied up.

Switching to incremental writing allows Action Cable to spread out writes such that a blocked socket can’t block writes to other sockets.

Callbacks leaves less backtrace lines

Callbacks — before_action and friends — moved forward by going back this week: back to the backtrace and removing traces of itself. Try that, McFly!

Check the description for an example, it’s quite easier to see in action.

Improved

Rails’ test runner supports after_run hooks

The Rails test runner switched to using minitest’s autorun across the board, as such it gained support for Minitest.after_run hooks.

autorun also guards against running tests twice, which could happen in some cases. But that’s now fixed too.

Fixed

Don’t leak ActiveModel::Errors default_proc

Previously when serializing ActiveModel::Errors via to_hash or as_json for instance, the default_proc would hide in the engine compartment and spring out when the crew was out of orbit.

No more of those alien capers on this ship!

Make :as option also set request format

In Rails 5 you can make an as of your test requests, as: :json that is.

After adding the option to ActionController::TestCase last week, we’ve opened the pod bay doors once ensuring the format is just right_._

Wrapping up

That’s it for this week, as usual there were more changes than what we can fit, feel free to check them yourself here!

Until next week!

This Week in Rails: 🍫 Your Golden Ticket to the Chocolate Factory 🍫

Jon here welcoming you to This Week in Rails!

Today we’ll be touring the wondrous Ruby on Rails chocolate factory to see how its marvelous candy, consumed by web apps and developers everywhere, is made and tested.

Golden tickets in hand? Let’s go!

Welcome! 🎩

This Week’s Rails Contributors

This week, 26 fabulous oompa-loompas concocted improvements to make your favorite candy even more delicious – including one for the first time!

Fix Bundler warnings about insecure github sources

If you upgrade to bundler 1.13 and use github options to specify gem sources in your Gemfile, you’ll see warnings when running bundle commands.

To fix, you can run bundle config github.https true on the command line.

Or if you don’t control the environment the Gemfile will execute in, you can add this to the Gemfile, like Rails now does:

git_source(:github) |repo_name| do
  “https://github.com/#{​repo_name}​.git”
end

Backported to 5-0-stable.

Improving the chocolate 🍩🍫

Puma docs: Disconnect connections before preloading

This pull request added documentation for config/puma.rb to recommend closing database connections if preloading an application that uses Active Record. See the discussions in the pull request and in puma/puma#1001 for more.

Improve assert_response helper

To improve productivity when writing tests, if an assert_response test fails, Rails nows outputs the actual response body if it’s not too large (less than or equal to 500 chars).

Fixing bugs in the candy 🍬

Clear attribute changes after touching

Following-up on a very good bug report, this PR fixed a Rails 5 regression so that calling ActiveRecord#touch when using optimistic locking once again leaves the model in a non-dirty state with no attribute changes.

Prevent mutation of constants

Tests using ActionDispatch::IntegrationTest were failing when run after any controller test that modified request.session_options. It turned out that  ActionController::TestSession::DEFAULT_OPTIONS was being mutated, and as a result, Rack::Session::Abstract::Persisted::DEFAULT_OPTIONS also, which made integration tests inherit that value and fail.

This pull request dup’ed the AC default options constant to prevent mutation, and a pull request to Rack was merged to freeze the Rack default options constant and avoid the issue in the future.

Force correct namespace with TransactionManager

This pull request fixed issue #26441: “NameError: uninitialized constant AR::ConnectionAdapters::DatabaseStatements::TransactionManager when calling reset_transaction”.

How to contribute? Some examples from this week 🍰

Fix warnings in the test suite

Running the Rails test suite can be a great way to uncover minor issues to fix. This pull request addressed 2 warnings in the test suite that arose simply from not wrapping a method argument in parentheses.

Add missing tests

Noticing that there were no tests for when ActiveRecord::Enum#enum was called with a specific suffix, this contributor added some.

Improve the Rails Guides

Better documentation is always welcome. After seeing issue #26286, this contributor helpfully improved the documentation for the render partial ‘as’ option.

Add a bug report template

The commit message says it all: “I created this for testing migrations in isolation and thought it would be helpful to others in the future to avoid having to dig through the Rails migration tests.”

Remove duplicate code

This elsif branch was a duplicate of the else branch just after it. You’ll never believe what happened next 😮.

How to inherit a world of unlimited imagination 🍭

That’s it for today’s tour, but the true journey has only just begun.

Starting today, choose any file in the Rails codebase and read it.

Pick an open issue on the master branch, and try to reproduce the bug using the Rails bug report templates.

Go through the Contributing to Ruby on Rails Guide. Set up your Rails test environment.

Pick an open pull request and test it or review it.

You’ll be surprised what baby steps like these can lead to!

Enjoy the wonderful chocolate – and see you next week.