This Week in Rails: yarn, webpack, BIGINT PKs and more!

Hello everyone, this is Godfrey reporting from Portland, OR. This week has been a mix bag for me – on one hand, Portland had a pretty miserable week due to the storm; on the other hand, a lot of exciting changes landed in Rails. Does that make things even? I guess we’ll go through the changes and you can decide for yourself!

“Yarn is good. Yarn works.”

Last week, we mentioned that Rails 5.1 is gaining a –yarn  option. This option is now promoted to be the default: every new Rails app will be set up to use yarn out-of-the-box. It’s also worth noting that yarn packages are now installed into the vendor/node_modules directory.

Basic webpack integration

While we are talking about JavaScript, the asset bundling side of things is also getting some love. Rails 5.1 will gain first-class support for webpack via the –webpack option. This is still a pretty early spike, so definitely try it out and help improve it.

Change default primary keys to BIGINTs

Friends don’t let friends use INT as a primary key – your app might hit Webscale™ before you know it, resulting in much sadness when your primary key column overflows. To help put you on the right path, Rails 5.1 will default to using BIGINTs for primary key columns in MySQL and PostgreSQL.

New

Introduce ActiveRecord::NotNullViolation error

As of this pull request, if your model failed to save due to a NOT NULL constraint, Rails will raise a NotNullViolation error (instead of a generic StatementInvalid error) so you could rescue the error and handle it appropriately.

Improved

Speeding up RSpec integration tests by 40%

This patch fixes an issue where templates are needlessly recompiled between integration test, resulting in a significant speedup.

Fixed

Idempotent after_commit callbacks

Previously, certain race conditions could cause your after_commit callbacks to fire more often than expected. This patch attempts to more accurately track the work that actually happened in the database to ensure your hooks are triggered only when appropriate.

Allow variales named block in templates

Have you tried using variables named block  in your templates? If you did, you might have seen a pretty strange error from Rails. Not anymore! With this patch, you would be able to do that without issues.

Exclude singleton classes from subclasses and descendants

A change in Ruby 2.3.0unexpectedly changed the behavior of Active Support’s Class#subclasses and Class#descendants  methods to include singleton classes. This patch restores the previous behavior and made things consistent across different versions of Ruby (again).

Wrapping up

That’s it from This Week in Rails! There were many other great contributions, so please feel free to check them out yourself!

Until next week!

[ANN] Rails 5.0.1.rc2 has been released!

Hi everyone,

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

If no further regressions are found, expect the final release on Wednesday, December 14, 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.rc2:

$ shasum *-5.0.1.rc2.gem
52c2dffc42e386aacf28f1033edd975804770bef  actioncable-5.0.1.rc2.gem
0bf7faf211a7d9413432c59a4700bea3b3a41975  actionmailer-5.0.1.rc2.gem
127a122087e941eb245f500dc000779fb85916c6  actionpack-5.0.1.rc2.gem
3622fcb6e46d1ff48c2a2c3e773ecad769c776e0  actionview-5.0.1.rc2.gem
0bf2518768da054b18b871d48107e3afe79e552f  activejob-5.0.1.rc2.gem
ff3e0ef08053bc439f71387410415bf2ddc937b8  activemodel-5.0.1.rc2.gem
7eba5d1214a24e8e0b0e32eaf0560a69b2d6a702  activerecord-5.0.1.rc2.gem
2e601cabcf09057b4322a0069ffb07df38955aa4  activesupport-5.0.1.rc2.gem
b9653fa0724a30cb9ffbb23e39340a0166916bd0  rails-5.0.1.rc2.gem
60c06b55dd5977d0c25f407e39f7325b150cd994  railties-5.0.1.rc2.gem

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

This Week in Rails: jQuery no longer part of Rails and more!

Hello everyone!

Prathamesh and Greg here, bringing you all the latest from This Week in Rails…..
Which is actually “Past 2 weeks in Rails” because we missed to send last week’s issue due to illness. But we are back now, so let’s see what happened in the Rails world since the last issue.

This week’s Rails contributors

The past 2 weeks 38 awesome people contributed to Rails. Want to be part of the show? Head to the issues list and make a contribution!

jQuery is no longer a dependency of Rails

The Rails javascript helpers has been rewritten in a new gem called rails-ujs and they use vanilla javascript, so jQuery is not a dependency of Rails anymore.

Rails 5.0.1.rc1 has been released!

The first release candidate for 5.0.1 has been released and if no issues found, the final will be release on the 6th of December.

Improved

form_with helper to unify form_tag and form_for

The form_for and form_tag helpers serve a very similar use-case so they been unified with the new form_with helper.

Make the second argument to attribute optional

A default for the cast_type option of the attribute method has been added to enable calling this method with just the attribute name.

Active Record connections improvement

Active Record distributed the connection to previously blocked threads on when it cleared the reloadable connections, but with this change the same happens on disconnect too.

Use gen_random_uuid() for PostgreSQL >= 9.4

With this change, Active Record uses the recommended UUID function depending on the underlying PostgreSQL server’s version, while maintaining uuid_generate_v4() in older migrations.

New

Add Yarn support in new apps using –yarn option by Liceth · Pull Request #26836 · rails/rails · GitHub

yarn, the javascript package manager is supported in Rails now! You can pass the –yarn option when you generate a new rails app and Rails will create the necessary config files and run yarn install after bundle install automatically.

Introduce reload\_ reader for singular associations

This patch introduced _Model#reload__ to bring back force reloading of the association reader.

Fixed

update_all and delete_all is fixed when chained with left_joins

These batch methods didn’t use the left outer joins before, but with this fix they behave properly now.

Fix a force ssl redirection bug

This PR fixes a bug with the force ssl redirection when the session_store is disabled.

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!

[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!