This Week in Rails: HTTP/2 Early hints, friendly error message and more!

Hi there! It’s Prathamesh from Pune, enjoying rain 🌧, sipping ☕️ coffee  and bringing you latest news from the Rails world. Let’s get started!

This Week’s Contributors

13 people contributed to Rails the past week! If you’d like to join them, why not check out the list of open issues?

HTTP2 early hints support for Rails

Early Hints is a new HTTP status code that allows your application to send links to assets that you would like to load early. The spec is still in draft but Rails is ready to support it along with Puma. Check this blog post to know more about this feature.

Friendly error message when unsubscribing from non-existent Action Cable subscription

If for some reason the frontend code tries to unsubscribe from a non existing Action Cable subscription, then a friendly error message will be displayed:

Unable to find subscription with identifier: {“channel”:”SomeChannel”}.

Earlier, it used to show:

NoMethodError - undefined method `unsubscribe_from_channel’ for nil:NilClass

Feel free to check out the full list of changes.

Thanks to the 13 people contributed to Rails last week. If you’d like to join them, check out the list of open issues. Until next week 👋 

This Week in Rails: New credentials configuration, bugfixes and more!

Hi there! It’s Greg, bringing you a double-edition of This Week in Rails!

This Week’s Contributors

28 people contributed to Rails the past two weeks! If you’d like to join them, why not check out the list of open issues?

Rails 4.2.10.rc1 released

Although Rails 4.2 is not officially supported anymore, this release fixes some regressions introduced by the previous one. If no new regressions found, the final should be released mid next week.

Introducing config/credentials.yml.enc

Rails 5.2 will introduce a new credentials configuration file to store encrypted data like API keys and the secret key base. This will eventually replace Rails.application.secrets and the encrypted secrets introduced in Rails 5.1.

Add with_attached_* scope

To avoid N+1 queries when using Active Storage, this PR added with_attached_* scope to the has_one_attached macro.

ActiveRecord::Associations::Preloader memoization improvement

With this change the association pre-loader became slightly faster.

Implement change_table_comment and change_column_comment for MySQL

change_table_comment and change_column_comment are implemented for the MySQL adapter as well now.

Fix Active Storage direct upload in Firefox

Direct upload in Firefox was not working because it can’t handle click events on input[type=submit], but this PR fixed the problem.

Capybara puma server configuration fix

This PR fixes an issue when the config/puma.rb configuration is loaded for system tests.

That’s it for this now! As always, there isn’t enough time to cover every change if you’d like check out the full list of changes yourself.

This Week in Rails: engine screenshots, method redefinitions and more!

Oh, hello there! I’m Tim, and if you’re reading this that means you’ve got Rails fever! It’s time for your weekly dose of This Week in Rails….

This Week’s Contributors

This week 21 people contributed to Rails, including 4 for the first time! If you’d like to join them and perhaps get a slot in next week’s edition, why not check out the list of open issues?

Support multiple version arguments for gems in generators

The gem method can now support multiple version constraints, just like in rubygems!

Make take_failed_screenshot work within engine

This method used to get the tmp directory relative to Rails.root, which in an engine points to the dummy application, where no such directory exists. This was fixed by using the path relative to the current directory instead.

Clarify intentions around method redefinitions

This fixed a race condition in class_attribute, which in redefining an attribute had to remove it first and then redefine it. If another thread was trying to access that attribute in the middle of that, it would raise a NameError. Thankfully no more!

….and that’s a wrap! As always, there is never enough time or space to cover every change this week, but we value each and every one. If you’d like to know more you can check out the full list of changes yourself. See you next time!

Image alt text gone, restart/cache command fixes and more!

Hello everyone!
This is Vipul from Rainy Pune ☔ , cozying up with a ☕, bringing you a recap of the changes  that made it to Rails this week.
If you too want to contribute to Rails, head over to the issues to help us out!

Do not generate default alt text in image tags

Previously Rails auto-generated alt text for an image from the file name if it was not provided with an image_tag. This generation could be distracting and fatiguing for screen reader users if not considered properly.

After this change, if authors leave images without alt text, Rails will not pre fill it anymore, leaving screen readers to prompt authors to fix the issue.

Prevent extra “SET time zone” in configure_connection

Previously Rails would end up setting database connection timezone twice, once if passed via configuration in configure_connection and secondly while setting default timezone.

This change removes setting timezone on database twice if timezone is already passed via configuration variables.

Add TransactionTimeout for MySQL error code 1205

This PR adds TransactionTimeout error to the MySQL adapter, which handles the error:
Lock wait timeout exceeded; try restarting transaction (MySQL error 1205)

Encode Content-Disposition filenames according to RFC 2231 in Active Storage

Before this change, urls for files with non-english names would create issues in Active Storage.

This change fixes encoding Content-Disposition for filenames to RFC 2231, to fix this issue.

For signed/encrypted cookies with ``:expires` like

cookies.signed[:user_name] = { value: "bob", expires: 2.hours }

Rails now embeds the expiry within the written cookie payload. This way Rails isn’t reliant on clients to honor the expiry, but can verify it independently server-side.

Make restart and dev:cache tasks work when customizing pid file path

Previously rails dev:cache failed to restart the Rails server when it was started with a custom pid file path.
With this change, restart no longer fails for a custom pid file and successfully restarts Rails server on dev:cache changes.

Fix can't modify frozen String error in display_image

This change does a quick fix for an error with display_image in System tests, which is used for screenshots, that used to raise an error when trying to modify a frozen string.

Fixes :inverse_of association option not working with eager_loading

Previously calling an eager_load on :inverse_of association failed. This was a regression from Rails 5.1 release. 

This change, fixes the regression.

That’s all for this week! Feel free to check the full list of commits if you are interested. Until next week!

Better docs, better performance, better Rails!

Hello everyone! This is Claudio with a recap of the main commits that made it into rails/rails this week. If you too want to contribute to Rails, this outstanding Active Record issue is a great place to start.

Temporarily point to a fork of SDoc

A work in progress to improve the documentation of Rails with a nicer theme, better SEO and faster generation time. Can you spot the difference between the current and the future version?

Minor tweaks in Active Storage documentation

Two weeks ago, Active Storage made it into rails/rails. This week its documentation has been improved to make it ready to ship with Rails 5.2.

Faster and more readable implementation of Hash#deep_merge

If you want to learn how to use benchmarks to prove that a commit can improve the performance of Rails, this is a great example.

Eager-load controller actions to reduce response time of the first request

The list of available actions for a controller is now eagerly loaded  to reduce response time of the first request and the memory footprint when running on forking server like Unicorn.

Load Parameters configurations on :action_controller only once

This PR fixes a regression introduced in 5.1.3 by which UnpermittedParameters were not raised as expected.

Check :scope input in Uniqueness validator

Without this patch, calling something like validates_uniqueness_of :code, scope: [archived: false] would cause NoMethodError with a trace into AR internals.

Add binary helper method to fixtures

You can now more easily use binary data as fixtures.

Add --skip-yarn option to the plugin generator

Don’t include yarn in your engines if you don’t need it.

Allow serialize with a custom coder on json and array columns

Better control on how to store your data.

Bump thor and blade

Thor 0.20 has new features you might want to look at.

That’s all for this week! Feel free to check the full list of commits if you are interested. Until next week!

Three new committers: George, Javan, Ryuta

We’re happy to announce three new members of the Rails committers team: George, Javan, and Ryuta 🎉!

  • George Claghorn: George has been an integral part in creating our new Active Storage framework. He wrote a substantial part of the framework itself by extracting hard-won lessons from his work at Basecamp on moving our storage to the cloud. George also managed the stand-alone rails/activestorage repository with issue and PR processing prior to its merge into the framework proper. George works at Basecamp and lives in Philadelphia.

  • Javan Makhmali: Javan has written the majority of the JavaScript needed for Action Cable and Active Storage, as well as being a significant contributor to Webpacker. He’s also the co-author of Trix and other JavaScript libraries and frameworks originating at Basecamp. Javan lives in Ann Arbor.

  • Ryuta Kamizono: Ryuta is a top 20 all-time Rails contributor with work going back to 2013. He’s got his fingerprints all over the framework, but have in particular been helping with Active Record. Ryuta lives in Tokyo.

As a reminder, the committer team works together with the core team by assisting with pull-requests processing and making changes to the framework, but does not have the keys to make final releases or set policy. All members of the core team came up through working on this team.

New releases, bugfixes and more than 30000 issues/PRs!

Hello everyone! This is Prathamesh with the latest news from the Rails world.

Rails 5.1.3.rc2 and 5.0.5.rc2 released

Two new release candidates has been released this week, if there are no regressions found, the final releases are coming next week! We said it last week as well 😁

This Week’s Rails contributors!

27 people helped to make Rails better this week with 7 of them for the first time! If you want to be one of them, checkout the issues list, help is always welcomed!

Rails crosses 30000 issues/PRs on GitHub

As of this writing the count is increased to 30004. 28805 of all of these issues and PRs have been processed already! That’s pretty awesome 🎉

Let Arel manage the bind params

Active Record no longer manages the bind parameters required for queries. Now Arel handles it on it’s own and returns the AST and bind params together. 

Add missing support for modulo operations on durations

Rails 5.1 introduced ActiveSupport::Duration::Scalar class as a wrapper around a numeric value as a way of ensuring a duration was the outcome of an expression. However the implementation was missing support for modulo operations. This is now fixed.

Fix division where the denominator is duration

This fixes a regression where result of division by duration was not returning Numeric result. It is now restored to the previous behavior of Rails 5.1.1 and prior.

That’s all for this week, as always, we couldn’t cover all of the changes, but feel free to check the commits if you are interested. Until next week!

New releases, bugfixes and more!

Hello everyone! This is Greg with the latest news from the Rails world.

Rails 5.1.3.rc1 and 5.0.5.rc1 released

Two new release candidates has been released this week, if there are no regressions found, the final releases are coming next week!

This Week’s Rails contributors!

28 people helped to make Rails better this week. If you want to be one of them, checkout the issues list, help is always welcomed!

Add bootsnap to default Gemfile

The bootsnap gem helps to boot a Rails application faster, and the gem is now part of the Rails default Gemfile.

Allow to pass a connection to the dbconsole command

With this change the dbconsole command can except a connection parameter, so if you are using a 3 level database connection configuration you can specify the connection you want to use.

Fix where with a custom table name

With this week the select clause will use the custom table name if you have a table alias set up.

Scrub the invalid parameter value before using it in the error

When Rack::Utils::InvalidParameterError is raised the exception message now scrubs the parameter value to make it possible to use it in error messages.

Make rails yarn:install ignore dev dependencies

With this change rails yarn:install won’t install the development dependencies, so in deployment when the assets are precompiled they are ignored. bin/yarn still installs everything in your development environment.

That’s all for this week, as always, we couldn’t cover all of the changes, but feel free to check the commits if you are interested. Until next week!

This Week in Rails: Active Storage, telling secrets and time travelling!

Hello everyone! This is Roque bringing you the latest news from the Rails world.

It’s been two weeks, so let’s begin!

Active Storage is coming to Rails 5.2

A brand-new framework for managing user uploads is coming to Rails ecosystem. The TODO list is full of ideas, and it’s a great opportunity to send a PR and improve the library.

This Week’s Rails contributors!

We had 24 people who helped make the Rails better this week. Two of them contributed for the first time ever! If you would like to help out, check the issues list.

New

rails secrets:show will tell secrets!

The command will the decrypt encrypted secrets and display them in your console if you have the key file.

Protect from forgery by default

You no longer need to enable the CSRF protection when creating new apps. They will be more secure by default.

Add time helper method freeze_time

The new helper method will travel_to Time.now freezing time. You can call it with a block or not.

Fixed

Prevent invalid PostgreSQL UUIDs

The UUID validation was allowing mismatched curly braces. The fix requires both a leading and a trailing curly brace, or neither.

Fix long Action Cable channel names for PostgreSQL

Action Cable will hash channel names with SHA-1 if they reach the limit of 63 bytes.

Improved

Change SQLite 3 boolean serialization to use 1 and 0

This change in serialization requires a migration of stored boolean data to use 1 and 0 , instead of 't' and 'f'. You can use this change by enabling the configuration: ActiveRecord::ConnectionAdapters::SQLite3Adapter.represent_boolean_as_integer = true

That’s it for this week, as always, we couldn’t cover all of the changes, but feel free to check the commits if you are interested. Until next week!

This Week in Rails: 5.1.2.rc1 released and faster fixtures

Hi there! This is Kir from chilling Ottawa, bringing you another edition of This Week in Rails. Let’s dive in.

🎉 This Week’s Rails contributors! 🎉

We had 21 awesome people who helped make Rails better this week, with one first-time contributor! Would you like to help as well? Head over to the 👉 issues list.

New

🎉 Rails 4.2.9.rc2, 5.0.4 and 5.1.2rc1 have been released 🎉

It’s your chance to help us discover bugs in 4.2.9 and 5.1.2 release candidates. Also, Rails 4.2.9 will be the last release in 4.2 series, so it’s time to upgrade if your app is still running on Rails 4.

Perf

Use bulk INSERT to insert fixtures

Inserting fixtures in test environment became significantly faster by using one bulk INSERT query instead of many single INSERTs.

Fixed

current_page? helper now works from within a Rails Engine

Due a bug related to a trailing slash, current_page? helper always returned false while it was supposed to return true when it was called from a Rails Engine route.

Keep INNER JOIN when merging relations

Now you can safely merge two ActiveRecord relations both having a JOIN. Previously, that would to query with LEFT OUTER JOIN instead of INNER JOIN.

That’s it for this week, as always, we couldn’t cover all of the changes, but feel free to check all the commits from this week.

Until next week! 👋👋

This Week in Rails: mailer configuration, perf improvement, and bug fixes!

Hi there! This is Andy, bringing you another edition of This Week in Rails. Let’s dive in.

🎉 This Week’s Rails contributors! 🎉

We had 23 awesome people who helped make Rails better this week, with 4 first-time contributors! Would you like to help as well? Head over to the 👉 issues list.

New

Allow mailers to configure their delivery job

In some situations, a user may want to configure the delivery job in order to have better control over errors. This adds an option to make that possible.

Perf

Improve performance of mass assignments

This change makes a small improvement to the performance of initializing an ActiveModel instance. The other interesting thing I learned about was the “magic comment” # frozen_string_literal: true. Check the PR for details.

Fixed

Don’t map id to primary key in raw_write_attribute

The hash provided to update_columns is turned into an UPDATE query. Passing an id key resulted in an update to the id column, even if the model uses a different primary key. This fixes that!

Docs

Docs for #delegate_missing_to

A newer feature, now with documentation explaining how and when to use delegate, and delegate_missing_to.

That’s it for this week, as always, we couldn’t cover all of the changes, but feel free to check all the commits from this week.

Until next week! 👋👋

This Week in Rails: default option for mattr_accessor, write_multi and more!

Hello everyone! Prathamesh here bringing you the latest news from the Rails world. Let’s get started 🚅

🎉 This Week’s Rails contributors! 🎉

We had 21 awesome people who helped make Rails better this week. Two of them contributed for the first time ever! Would you like to help as well? Head over to the 👉 issues list.

New

💪 mattr_accessor gets the default option 💪

Followup to adding the default option to the class_attribute macro, it is now added to mattr_accessor family of methods as well.

It can be used as follows:

mattr_accessor :always_write_cookie, default: false

💪 Write multiple cache entries at once with write_multi 💪

A new method write_multi has been added to the cache stores which writes multiple cache entries at once.

For eg.

Rails.cache.write_multi foo: ‘bar’, baz: ‘qux’ The default implementation just calls write_entry one by one for each entry but specific cache stores can override this behavior as per their ability of doing bulk writes.

Fixed

⚡️ Generate field ids in collection_check_boxes and collection_radio_buttons ⚡️

This change fixes an issue with collection checkboxes and radio boxes where clicking on the labels was not selecting the options because the input elements did not have proper id attribute with respect to their labels.

✨ Fix partial cache logging getting attributed to wrong partials ✨

This commit fixes an issue with the cache hit/miss log markers being applied to wrong partials.

That’s it for this week, as always, we couldn’t cover all of the changes, but feel free to check all the commits from this week.

Until next week! 👋👋

This Week in Rails: class_attribute default, mini_racer and more!

Hello everyone! This is Roque bringing you the latest news from the Rails world.

This Week’s Rails contributors!

We had 32 people who helped make Rails better this week. Three of them contributed for the first time ever! If you would like to help out, check the issues list.

Allow a default value to be declared for class_attribute

Rails will now make it easier to set default values to class attributes like class_attribute :timeout, default: 5

Replace therubyracer with mini_racer

New apps generated with JavaScript and Sprockets support will use mini_racer for the Ruby platform. A faster and more reliable interpreter.

New

Add previous and next day of week API to Active Support

The methods prev_occurring and next_occurring expect a day of the week and return the appropriate value based on the DateTime, e.g. DateTime.now.prev_occurring(:monday).

Fixed

Fix number_to_human round calculation

This fix a regression introduced in Rails 5, where a case like number_to_human(1_000_000, units: { unit: 'meter', thousand: 'kilometer' }) would return "1" instead of "1000 kilometer".

Fix pluralization of uncountable expressions when given a locale

Previously, methods like pluralize and singularize would only use the English uncountable rules rather then the ones for the locale that was passed.

Rename primary key index from rename_table

Formerly, rename_table would only rename primary key index if the column’s data type was sequential. Tables with primary keys with types like UUID would still keep the old name.

Improved

Allow additional options for poltergeist or capybara-webkit in System Tests

If using poltergeist or capybara-webkit, driven_by will register it as the driver and set additional options passed via :options param.

Please refer to drivers documentation to learn what options can be passed.

That’s it for this week, as always, we couldn’t cover all of the changes, but feel free to check the commits if you are interested. Until next week!

This Week in Rails: ActiveSupport::CurrentAttributes, AEAD and more!

Hi there!

This is Vipul bringing you all the latest news about Rails from the hopefully ending summer here in Pune🔥

This Week’s Rails contributors!

We had 36 people who helped make Rails better this week.
Six of them contributed for the first time ever!
If you would like to help out, check the issues list.

New

ActiveSupport::CurrentAttributes provides a thread-isolated attributes singleton

If you’ve used current_user from Devise, you’ve already come across what CurrentAttributes partly provides, but wait there’s more!

Using CurrentAttributes you can start using per request variables that are accessible across the whole system like Models, Controllers, Views, during a Rails request cycle.

For example you can start using attributes like current_user, account, etc, and much more that your system might need without passing them all around to different methods.

AEAD encrypted cookies and sessions

Encrypted cookies now use AES-GCM which couples authentication and encryption in one faster step and produces shorter ciphertexts.

Older cookies encrypted using AES in CBC HMAC mode will be seamlessly upgraded when this new mode is enabled via the action_dispatch.use_authenticated_cookie_encryption configuration value.

Fixed

Make secrets:edit run secrets:setup if it hasn’t already.

On a new app, if you did rails secrets:edit before you’ve called rails secrets:setup, Rails would throw an error.

With this addition, Rails takes care of doing that for you if not already done.

Fix regression in Numericality validator

This change fixes a regression in Numericality validator where extra decimal places on a user input for a decimal column were ignored by numerically validations, for example when comparing 9.18 vs 9.179. 

Improved

Active Record initialization optimizations

Rails had a performance regression from 4.2x to 5.0 where initialization of records slowed down by factor of 2x in some cases.

This change optimizes initializations to improve by a factor of 2x for STI models and 1.3x for non-STI models

That’s it for this week, as always, we couldn’t cover all of the changes, but feel free to check the commits if you are interested.
Until next week!

This Week in Rails: Recycled cache keys and more!

Hi there! This is Greg with the latest news about Rails!

This Week’s Rails contributors!

22 person worked on making Rails better this week. Big thanks to them!
If you want to be a part of that, check the issues list!

New

Recyclable cache keys

With this change Rails, will be able to recycle the cache keys and if you have big volume cache write, your cache space will be better utilised.

Fixed

Allow irb options to be passed from rails console command

Pre Rails 5, the rails console accepted irb options, but a change in Rails 5 break that feature. Now it is fixed, so you can pass the options like this:  rails c – –simple-prompt.

Improved

Respect SchemaDumper.ignore_tables in databases structure dump

This change makes Active Record respect the ignored tables if you configured any.

Don’t cache locally if unless_exist was passed

If your cache backend supports the unless_exist option, you can configure Rails to delete the local cache and read the correct value from the backend.

That’s it for this week, as always, we couldn’t cover all of the changes, but feel free to check the commits if you are interested.
Until next week!

This Week in Rails: hooks, fixtures, fetch_values, database connections and more!

Hi there! This is Andy with another edition of This Week in Rails. This week we’re covering two weeks worth of changes, so let’s dive right in.

New

Hooks for action_controller_base and action_controller_api

This change breaks out two Action Controller hooks, where there was one before. action_controller_base and action_controller_api. These can be used to load less code at boot time.

Fixture accessor with no arguments

Do you need to load all the fixtures of a particular type? Calling a fixture accessor method with no arguments returns all fixtures.

Implement fetch_values for HashWithIndifferentAccess

Add fetch_values for HashWithIndifferentAccess in Rails, added to Ruby in 2.3.0. Support was added conditionally by using method_defined?.

Fixed

Clear active connections after initialization

If your app uses a lot of database connections, this one is worth a look. The author said that after deploying this change, they reduced their peak open database connection count by 13%.

Fix mistake in JS response parser

This change restores the ability to accept ecmascript for parsing. The author also declares that the JS response should not modify the DOM. Take a look!

Improved

Doc improvement for before_destroy

Did you know that before_destroy hooks should be set *before* dependent: destroy for it to work correctly? This documents that.

Don’t freeze input strings

Check this out if you’re curious about changes around frozen strings and usages of Immutable String (Matz said “All String literals are immutable (frozen) on Ruby 3”).

Whew! That covers just some of the changes in the first couple of weeks of April. Many other great pull requests are available to browse, from 27 contributors including 5 first-timers. Nice work!

Until next week!

This Week in Rails: -j smoked, 42, designated drivers and more!

Yo folks! Your noble editor Kasper here with the latest and greatest from Rails.

Check the fine print 📰

Remove rails new –javascript

The –javascript option for new Rails apps could install any gem ending in -rails. From now you’ll have to add jquery-rails to your Gemfile manually.

Properly sourced fourty_two

The new documentation now has the answer to life the universe and everything.

New

Per subclass system testing driver overrides

Your system testing test case subclasses all have a designated driver. Now you can designate another driver in case the test case calls for it.

reverse_merge aliased to with_defaults

One for the aesthetics department: with_defaults has emerged as an alias for_reverse_merge_. So now_options.with_defaults(creator: @current_user)_makes your intent clearer.

Fixed

Fixed rails-ujs.js module support

Once Rails 5.1 ships proper you’ll be able to require rails-ujs from your JS again.

There were many other great pull requests this week from 45 contributors, including 8 first-timers. Thank you all!

Until next week!

This Week in Rails: 5.1.0.rc1, GSoC and more!

Hello everyone! This is Roque bringing the latest from the last two weeks.

The last couple of weeks have been very busy with the releasing of Rails 5.1.0.rc1 and the starting of Rails 5.2 🎉

Congratulations to all involved!!

Rails 5.1.0.rc1 has been released!

Please check it out and help the community by reporting issues before 5.1 is released.

If you are already using encrypted secrets, make sure to run this script to upgrade your app.

Google Summer of Code 2017

Are you a student, or know someone who would love to contribute to Rails? Our GSoC students application is now open! Check out our ideas page and join us on the mailing list for discussion.

The RailsConf 2017 schedule is live!

Have you also been waiting for this? No more. The schedule is live and looks awesome!

New

Add default option to belongs_to

The :default option adds a before_validation callback that initializes the association with the given lambda’s return value:
belongs_to :person, default: -> {​ Current.person }​

Add support to duplicable Rational and Complex

This is a work ahead of the upcoming Ruby changes.

Fixed

Allow Time#to_time on frozen objects

This fixes an issue with frozen that has been around since Rails 4.

Allow order to be given expressions as hash keys

The Active Record order method is no longer restricted to attribute names. It now accepts expressions like:
Post.order(“LENGTH(title)” => :asc).last

There were many other great pull requests this week from 45 contributors, including 8 first-timers. Thank you all!

Until next week!

This Week in Rails: looots of fixes after the release and more.

Hello!

This is Vipul reporting from Delhi today, on this colourful Holi weekend 💥
 
Lets take a look at what’s the latest news from the world of Ruby on Rails !
So many fixes and much more.

Google Summer of Code 2017

We’re very happy to announce that Ruby on Rails has been accepted as an organization for the Google Summer of Code (GSoC) 2017 edition!

Fixed

Make sure local cache is cleared even if it’s throwing error

When an error was thrown from the middleware chain, it was sometimes not getting caught by LocalCache::Middleware.

This change, makes sure that we safely catch the errors and local cache is successfully cleared.

Fix rake db:schema:load with subdirectories

Previously db:schema:load didn’t work with migrations based out of subdirectories.

This change starts using Migrator.migration_files in assume_migrated_upto_version to fix the issue.

Fix malformed asset_url in ActionController::Renderer

This change fixes an issue with malformed asset_url when rendering a template with ActionController::Renderer.

Fix select with block doesn’t return newly built records in has_many association

The select method in QueryMethods is also an enumerable method. Ideally, enumerable methods with block should delegate to records on CollectionProxy and not the scope.

This change fixes this behaviour that select with block doesn’t return newly built records in has_many association.

Update titlelize regex to allow apostrophes

In a previous fix the regex in titlelize was updated to not match apostrophes to better reflect the nature of the transformation.

Unfortunately this had the side effect of breaking capitalization on the first word of a sub-string, eg:

>> "This was 'fake news'".titleize
=> "This Was 'fake News'"

This change fixes this behaviour by extending the look-behind to check for word character apart from an apostrophe.

Fix deserialize with JSON array

JSON array data was being returned in a stringified form, due to broken deserialization.

This change fixes deserialization behaviour.

Deprecated

Deprecate Migrator.schema_migrations_table_name

SchemaMigration model was extracted and SchemaMigration.table_name was being used instead in places where Migrator.schema_migrations_table_name was being used previously.

Migrator.schema_migrations_table_name is now deprecated in favour of SchemaMigration.table_name.

Improved

Added reverse_merge/reverse_merge! to AC::Parameters

This change adds the reverse_merge and reverse_merge! methods to ActionController::Parameters, similar to their corresponding Hash methods.

Do not take screenshot if driver does not support screenshot

Capybara::RackTest::Driver does not support taking screenshots. If we call #save_screenshot on Capybara::RackTest::Driver , it will raise an error.

To prevent errors, if a driver in Systems test does not support screenshot, we do not call it after this change.

There were many other great pull requests this week from 20 contributors, including 4 first-timers. Thank you all!

Outside of code changes, we had many more good news this and the previous week.

Until next week!

This Week in Rails: 5.0.2 released, stronger Encrypted Secrets and more

Hello!

It’s Claudio from sunny Los Angeles bringing you the latest news from the world of Ruby on Rails. So many improvements this week so… let’s get to it!

Rails 5.0.2 has been released!

Go on and update your Rails 5 app to the latest release!
v5.0.2 is fully backward-compatible with v5.0.1 and v5.0.0.

Google Summer of Code 2017

We’re very happy to announce that Ruby on Rails has been accepted as an organization for the Google Summer of Code (GSoC) 2017 edition!

Improved

Update secrets to use modern crypto

As announced last week, Rails 5.1 will include encrypted secrets. Thanks to this PR, the secrets will use a stronger cryptographic algorithm for enhanced security.

New

Add iso8601 and rfc3339 parsing to timezones

ActiveSupport::TimeZone now has a new rfc3339 method to get an RFC 3339 timestamp in a specific time zone.

Use webpacker 1.0 in new applications

In case you missed it, rails/webpacker is out of beta development and has recently released v1.0.

Fixed

Only load SystemTestCase if Puma is defined

System test cases (Capybara) are one of the new features in Rails 5.1. Since they only support Puma, they are skipped if Puma is not present.

Do not evaluate :if arguments when :on is not satisfied for transaction callbacks

Understanding when callbacks are run can be tricky. This PR smartly avoids running them as soon as one of the preconditions is not met.

Update DateTime#change to support usec and nsec

If you need to change a timestamp by a matter of microseconds and nanoseconds, now you can do it!

Deprecated

Soft-deprecate the HashWithIndifferentAccess constant

If you use HashWithIndifferentAccess in your code, you might want to look at using ActiveSupport::HashWithIndifferentAccess  instead.

Deprecate implicit coercion of ActiveSupport::Duration

A snippet of code like 2 * 1.day will display a warning, inviting you not to coerce a Duration into a Numeric since it can be confusing, because adding/subtracting a value from a date treats integers as a day and not a second.

There were many other great pull requests this week from 35 contributors, including 12 first-timers. Thank you all!

Outside of code changes, we had many more good news this week.

Until next week!

This Week in Rails: 5.1.0.beta1 release, Encrypted Secrets, System Tests and more!

Hi everyone,

Greg here with the latest from the world of Rails. It was a busy week with new releases and many improvements!

New Rails releases

The first beta release for 5.1.0 is out with some love towards JavaScript, System Tests, Encrypted Secrets and more!
There is also a new stable release for 4.2.8 and a release candidate for 5.0.2

Eileen joins Rails core

We’re proud to welcome Eileen M. Uchitelle to Rails core!

This week’s Rails Contributors

33 developers contributed to Rails this week. If you want to be part of this team, look at the issues list and make a contribution!

New

Custom url helpers and polymorphic mapping

This pull request introduces support for custom url helpers and defining custom polymorphic mappings in routes.rb

Capybara Integration with Rails (AKA System Tests)

Rails has a built in integration with Capybara now which makes writing system tests easier, since all the setup is handled by Rails. For more details read the write-up on the pull request.

Encrypted secrets support

Rails introduces secrets encryption which is inspired by the Sekrets gem.
It worth noting here that, some improvements to the crypto is on the way too.

Improved

Include JobID in all Active Job info logs

Earlier the JobID wasn’t logged when a job started or ended performing, but that’s not the case anymore, making debugging of job related issues easier.

From now on ActiveSupport::Gzip.decompress checks the CRC in the gzip footer.

Allow 3-level configs to group database connections by environment

If you have multiple database connection per environment, you can group your config by the environment. Check this comment for an example.

Delegate to scope rather than merge! for collection proxy

A performance improvement by not using merge! when it is not necessary.

Fixed

Preload to_datetime before freezing a TimeWithZone instance

After freezing an ActiveSupport::TimeWithZone instance, it is not possible to call to_datetime because the value is cached in an instance variable. To avoid this issue, the instance variable is preloaded before the freeze occurs.

HashWithIndifferentAccess#compat nil issue fix

HashWithIndifferentAccess#compact returned nil earlier when the hash didn’t contain nil values in it. This PR fixed the problem.

Deprecated

Deprecate using quoted_id in quoting / type casting

Originally quoted_id was used in legacy quoting mechanism. Now we use type casting mechanism for that hence quoted_id is deprecated.

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: Freeze strings related to caching, query optimization for Postgres and more!

Hey everyone 👋

Prathamesh here with the latest from the world of Rails.

⚡️This week’s Rails contributors ⚡️

This week was full of improvements and bug fixes. We have 24 awesome people contributing to Rails with 3 first-timers!

Improved

This change freezes the common strings used for fragment caching reducing the string allocations every time a read/write operation is performed on the fragment cache. The patch showed proper object allocation benchmarks showing a noticeable improvement, so it was accepted.

Optimize query for finding primary keys of a Postgres table

This change simplifies and optimizes the query used to determine the primary keys of a PostgreSQL table improving the overall setup time.

Fixes

Fix generator command for namespaced Rails engines

This change fixes the default generators to create proper namespaced resources for a namespaced Rails engine. For e.g. if we have a namespaced engine bukkits-admin , then

bin/rails g scaffold User name:string age:integer

will now correctly create

admin/app/controllers/bukkits/admin/users_controller.rb.

remove_index method can remove expression indexes now

Now, remove_index method can also be used to remove expression indexes apart from simple column indexes.

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

See ya next week 👣

This Week in Rails: Ruby 2.4 on Rails 4.2

Hello! This is Tim , bringing you another edition of This Week in Rails.

This week’s Rails contributors

This week saw contributions from 26 contributors, including 4 for the first time! What a fantastic bunch!

Rails 4.2.8.rc1 has been released!

If you’re using Rails 4.2, you may want to get a head start by trying out the release candidate for the latest patch release. It’s the first Rails 4 release to support Ruby 2.4, so see if you can give it a try to help us iron out any kinks!

Improved

Deprecate locking of dirty records

ActiveRecord::Base#lock! and #with_lock reload the record before doing the actual locking. If there were any unsaved changes, they will be discarded without any warning. When this work is completed in Rails 5.2, an exception will be raised when trying to lock a dirty object. Until then, support for this has been deprecated, so keep an eye out for warnings like these!

Remove support for strings in callback conditions

If you’ve seen deprecation notices concerning strings used in if and unless conditions in callbacks, listen up! Support for these have now been officially removed. Time to update, if you haven’t already!

Fixes

Allow ActiveRecord::Base.as_json to accept a frozen Hash

As you may know, ActiveRecord::Base.as_json takes an (optional) options hash. That hash is modified internally, but Rails is nice enough to clone it first so that it doesn’t change the thing you passed to it. If your thing was frozen however, it would cause it to blow up! How can this be so, I hear you ask. Well, when you clone an object, you also clone its frozen-ness. dup , on the other hand, does not do this, which turned out to be the solution. Case closed!

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!

See you next week!

This Week in Rails: Fresh code to fight the Winter doldrums

Hello! This is your host Andy, bringing you another edition of This Week in Rails.

I’m in a cold Northern climate ❄️️ and we’re in the middle of Winter right now. To me, it’s the best time of the year to stay inside and dive into some new code. Let’s take a look at some of the latest changes made to Ruby on Rails in the past week.

This Week’s Rails Contributors

We had 31 contributors this week. There are lots of PRs for bug fixes which are nice to see. Many thanks to all of the contributors!

New

Add warnings option to test runner

This change provides an option to enable Ruby’s warnings in tests.

Improved

Refactor Active Record reflections

This PR refactors reflections such that we can iterate over each reflection and ask the reflection object what scopes should be applied to the query we are currently building.

Report the attribute on ActiveRecord::SerializationTypeMismatch

When a ActiveRecord::SerializationTypeMismatch error occurs, we will now know which attribute caused the error.

Simplify query in column_definitions() for Postgres

This patch updates how column_definitions() for Postgres is calculated. The author has a nice usage of the EXPLAIN tool, to show that the new implementation is more efficient.

Fixes

Reload through_record that has been destroyed

For has_one :through associations, if through_proxy is not reset, setting a new record causes the runtime error Can’t modify frozen hash.

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!

Catch you next week!

This Week in Rails: Mailer preprocessing and new ERB handler

Steampunk! It’s all the rage with the kids these days.

Honestly, I was going to work this better into the lead but then I ran out of… ssssstea… 🤓

Anyway friendo! Here’s what Kasper dug up from this week in Rails.

This Week’s Rails Contributors

This week we got 33 committers: welcome or hello again! Either way, you all seem to be on the right track 😉

Action Mailer Preprocessing

Incoming! Mailers can now use params allowing for easier preprocessing with before_action akin to Action Controller. To enable call mailers like this: InvitationMailer.with(invitee: person).account_invitation.deliver_later

See the pull request for a considerable A/B example.

Rails uses Erubi for ERB handling

For many years Rails has used Erubis to handle ERB templates, but it’s been deprecated in favor of Erubi. Being 1/6 shorter to type is far from the only thing Erubi has going for it, so dip into the pull request for the full list 😄

One more thing

Steampunk! It’s hip, it’s wholesome and for the whole family.

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!

See ya!

New Action Pack caching gems released

Hi everyone,

I’m happy to announce that new versions of the caching gems extracted from Rails 4.0 have been released.

Action Pack Page Caching (v1.1.0)

CHANGES since 1.0.2

  • Support for Rails 5.0
  • Support for setting page_cache_directory at the controller instance level
  • Support for setting page_cache_directory using a proc, symbol or callable object

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 this SHA-1 hash.

$ shasum actionpack-page_caching-1.1.0.gem
b9626f7afeb1d69267d1fd6b7255a30be7c33d29  actionpack-page_caching-1.1.0.gem

Action Pack Action Caching (v1.2.0)

CHANGES since 1.1.1

  • Support for Rails 5.0
  • Respect Accept header when caching actions
  • Standardise behavior of options :layout and :cache_path when passed a proc, symbol or callable object

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 this SHA-1 hash.

$ shasum actionpack-action_caching-1.2.0.gem
308c3acf35c0bdbf15e5c63b64aeda0ec817a269  actionpack-action_caching-1.2.0.gem

Many thanks to the numerous people who have contributed PRs and reported bugs.

This Week in Rails: DB adapters, Git, Action Cable and more!

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

Remember, today is the last day to submit your RailsConf proposal. You have until 11:59 p.m. MST!

Now, let’s get started!

This Week’s Rails Contributors

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

SQL Server adapter released for Rails 5

The 5.0.x version of the adapter is only for the latest 5.0 version of Rails. If you need the adapter for an older version of Rails, just install the latest version of the adapter that matches your Rails version (3.2.x to 4.1.x).

Git repo in new Rails projects

New projects will now be generated with a Git repo by default. Please use the option --skip-git if you choose to skip it.

Foreign Key Support for SQLite

Adds foreign key support for SQLite 3.6.19 (or greater) in create statements.

Improved

Improve the AS::NumericWithFormat#to_s memory allocation

Thanks to some good profiling, ActiveSupport::NumericWithFormat#to_s should behave better and not allocate too many objects. 🔎

Fixed

Add channel prefix support to Action Cable Redis adapter

Without channel prefix in Redis, apps using the same Redis server could have their communication compromised. You can now set the option channel_prefix in your cable.yml file. Please check the PR for details.

Make all Rails commands work in engines

The following commands are now working in engines: server, console, dbconsole and runner.

Generate migrations at custom path

New database migrations will be generated at the path set by config.paths["db/migrate"] if the option is defined.

Fix Module#parent_name on a frozen module

The method would throw a runtime error when called for a frozen module.

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: Time, Duration fixes and more

Happy new year (yet again) ! And a Friday the 13th 👻

This is Vipul, bringing you the latest from just the second week of the year, which is shaping to be really busy.

Thanks to all the 27 contributors, in particular to the 4 people who contributed for the first time. Keep up the good work!

Here are the most relevant changes to Rails master for this week.

Improved

Constant look-up would no longer fall back to top-level constant since Ruby 2.5

Since top-level constant lookup has been removed on Ruby 2.5, Rails takes care of relevant changes on its side, so that we rely on properly scoped constants, instead of relying on fallback lookup.

Fixed

Fix pool_from_any_process to use most recent specification

If a process is forked more than once, the Active Record connection pool was grabbing the oldest connection specification for a process, and not the most recent one.

This issue is not seen for single processes, but if you are forking the process multiple times, the wrong specification will be returned and incorrect connection will be used.

This change fixes the issue by reversing the list of specification names so we can grab the most recent one rather than the oldest.

Make time travel work with subclasses of Time/Date/Datetime

Previously when using time travel methods, travel_to, etc, and calling now on a subclass of e.g. Time, it would return an instance of Time instead of returning an instance of the subclass.

This change fixes the way we return the instance, so that we always return using the correct class.

Fix inconsistent parsing of Durations with both months and years

Previously the following code may fail or succeed depending on the current time.

ActiveSupport::Duration.parse(2.months.iso8601) == 2.months  
ActiveSupport::Duration.parse(3.years.iso8601) == 3.years

This change fixes the inconsistent parsing so that this comparison no longer fails.

Removed

Deprecate reflection class_name option to accept a class

The idea of class_name as an option of reflection is that passing a string would allow us to lazy autoload the class.

Using the class directly, with something like

belongs_to :client, class_name: Customer

is eagerloading models more than necessary and creating possible circular dependencies.

This option is now deprecated, pass strings of the class names instead.

Wrapping up

That’s it from Vipul . I hope you enjoyed this issue. 

If you haven’t already, start working on those RailsConf proposals, you have only 6 days left to submit a good talk!

This Week in Rails: Starting the year with over 100 commits

Happy new year! How was your holiday break? Did you receive nice presents? In case you missed it, Ruby 2.4.0 was released on Christmas day so if you haven’t done it yet… rbenv install 2.4.0 right now!

The first week of 2017 has seen more than 100 commits to rails/rails. Congratulations to all the 32 contributors, in particular to the 8 people who contributed for the first time. Keep up the good work!

Here are the most relevant changes to rails master for this week.

New

Allow to set custom content type for email attachments

With Action Mailer it’s now easy to specify the content type of your attachments. E.g.: mail(body: "\<h1\>Hello\</h1\>", content_type: "text/html").

Added option to ActiveRecord::CounterCache methods

You can now ask Active Record to update specific timestamp columns when incrementing, decrementing, resetting, or updating counter caches.

Default Rails.env to development when missing

If your app does not set RAILS_ENV or RACK_ENV then the value of Rails.env will fall back to development rather than just being an empty string.

Improved

Improve Array#sum with Ruby refinements

Array#sum was defined in Rails with a monkey-patch. Ruby 2.0 introduced refinements for better encapsulation. This is the first PR where they are being used in rails/rails.

Ensure Rails 4.2 works with Ruby 2.4

Some tests and code have been fixed and backported to 4-2-stable so that running Rails 4.2 on Ruby 2.4 will not raise any error. 

Change return value of duplicable?

In Ruby 2.4, NilClass, FalseClass, TrueClass, Symbol and Numeric all support dup. For consistency, duplicable? will now return true for all these classes.

Fixed

Serialize JSON attribute value nil as SQL NULL

The way in which a nil JSON payload is stored in a database was inadvertently changed in Rails 5.0. This fix maps nil to SQL NULL, exactly as how it was in Rails 4.x.

Fix generator command for nested namespaced rails engines

If the name of your Rails engine has a hyphen then this PR (fixing the path of namespaced controllers) is for you! 

Update cookies helper on all HTTP requests

This fixes a regression by which cookies were only updated on GET requests. Now we will update the helper for all requests.

Removed

Remove support for MySQL

MySQL 5.0 reached “end of life” more than five years ago. Rails now requires at least version 5.1.10.

Remove previously deprecated code

By now, you should have already dropped any reference to Rake’s db:test:clone, Configuration’s serve_static_files and static_cache_control and ActiveRecord’s uniq, uniq!, uniq_value, insert_sql, update_sql, delete_sql.

Wrapping up

That’s it from Claudio. I hope you enjoyed this issue. And now… let me go back to writing my RailsConf proposal… I only have 14 days left to submit a good talk!

See you all in Phoenix at the end of April!

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!

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!

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.

This Week in Rails: Ruby 2.4 compat, attachments in preview emails, fixture_file_upload and more!

Howdy everyone!

This is Prathamesh bringing you the changes from this week in Rails!

This Week’s Rails Contributors

This week we had 22 awesome people making Rails better. We also had 3 people contributing for the first time. 

One more step towards Ruby 2.4 compatibility

Ruby 2.4 is coming! If you have already tried it with Rails 5, a key must be 32 bits error was raised due to a breaking change in Ruby 2.4 related to openssl cipher key lengths. It is now fixed, while keeping backward compatibility with any existing signed data. 🎉

Improved

Allow download of email attachments in the Mailer Previews

Now we can download email attachments in mailer previews similar to real-world emails thanks to this change.

Fixed

Make fixture_file_upload work in integration tests

This change makes sure that the  fixture_file_upload   test helper works properly in integration tests. In case you missed it, integration tests are the default way of testing controllers in Rails 5.

Use proper test adapter for Active Jobs inheriting from ApplicationJob

Rails 5 introduced ApplicationJob as the default base class for Active Job classes. When testing these classes, the proper test adapter was not being invoked due to looking for subclasses of ActiveJob::Base instead of its descendants. This change fixes it.

Wrapping Up

Although I enjoyed reviewing all the commits from the last week, there were as usual too many to mention exhaustively. But do check them out yourself here!   Until next week!

This Week in Rails: Speedier Times, Explicit Public Assets and more!

Oh, hello there!

This is Tim here bringing you your latest installment of This Week in Rails. We had another corker this week chock full of great updates - read on for the full details!

This Week’s Rails Contributors

This week saw 99 commits from 27 fantabulous people contributed to Rails, including an amazing 5 first-timers! If you’d like to see your name up there next week, why not take a gander at the issues board, or you may even consider the next item for inspiration….

Documentation Galore

This week saw a whopping 11 documentation PRs successfully merged. Improvements to the documentation are not only gratefully received, but are a great way to start getting involved.

Improved

Make public asset use explicit

When calling asset_path with an invalid file name, this method would simply pass the string that you gave it back to you. This revision adds a configurable flag called unknown_asset_fallback which when set to false will raise an error if the asset is not found. Setting it to true will preserve the current behavior, but will indicate that it is being deprecated.

Don’t unnecessarily load a belongs_to when saving

This change prevents an already-loaded model from being reloaded if its id gets assigned to another model in a belongs_to association and then saved.

Fixed

Fix performance regression in TimeWithZone#to_time

Up until Rails 4.0.0.beta1, TimeWithZone#to_time could return a cached instance attribute. Since that release it has been coercing the value to a Time on each call. This revision reverts the old behavior, which, according to the author’s benchmarks, is over 5 times faster.

Allow send_file to declare a charset

Previously, calling send_file with type: "text/calendar; charset=utf-8" , would result in the charset’s being deleted - a bug that was fixed in this PR.

Wrapping Up

Although I enjoyed reviewing all the commits from the last week, there were as usual too many to mention exhaustively. But do check them out yourself here!

Until next week!

This Week in Rails: Bad Puns, Dad Jokes And Other Useless Information!

Hello there!

Yes, this is Godfrey again. I am glad a lot of you found last week’s Cool Trick™ useful. However, wouldn’t life be pretty boring if you just keep getting useful information? So I figured I would change things up a bit by delivering you an issue full of bad puns, dad jokes and other useless information. Let’s get to it!

This Week’s Rails Contributors

This week, 11 new contributors along with 19 other returning contributors took some time to keep Rails chugging along.

Include The Content of “The Flash” In ETags

When confronted about code bloat, DHH does not take it lightly. This week, he pulled another one of those moves by committing the content of The Flash into the Rails codebase.

Redirect POST Requests With 307 Status Code

Chirag Singhal decided to stir up some drama here by sending browsers a HTTP 307 “YOU JUST DON’T GET IT” status code when upgrading POST/PUT/DELETE requests to HTTPS connections.

Remove over meta programming in AR::Relation

When Bogdan Gusiev dived into the AR::Relation code base, he was not pleased with what he saw. After making some tweaks in this PR, he seemed happy with the result. Why?

Well.

( •_•)>⌐■-■

(⌐■_■)

It doesn’t meta anymore.

YEEEEAAAAAAAAHH

Improve tag_option performance

Amadeus Folego identified  tag_options  as a hotspot in his application and decided to help improve its performance by throwing in some frozen strings. Cool!

Update docs with Action Cable Redis dependency

Coming back from his vacation, Rafael Reggiani Manzo redis™covered a new dependency for developing Rails. To ease the shock for the next person, he added the setup instructions to the guides.

Missing key should throw KeyError

Last but not least, Eileen M. Uchitelle committed a key error this week.

Wrapping Up

That’s all from me this week, I hope you find this information useless! For a more informative view, check out (no pun intended) the commits here.

Okay, please don’t unsubscribe! 😭 Your favorite rotation of editors will be back starting next week to replace me, so I’m sure things will get better from here!

Promise!

This Week in Rails: Read Me To Learn A Cool Trick™!

This is Godfrey, reporting in from Portland, OR. We have a lot to cover this week, let’s dive right into the stories so you can go back to watching Olympics!

👀
👅

Cool Trick™

Router Visualizer

Have you ever wondered what happens when you visit a URL (say /posts/5 ) in your Rails app? How does the Rails router know where to send your users?

The first (of many) step is to compare the URL against the routes table for potential matches. To make this lookup as fast as possible, the routes table is pre-compiled into a finite state machine, specifically a nondeterministic finite automaton (NFA).

If that sounds very intimidating, don’t worry! The Rails router actually comes with a debugging tool that could generates an interactive visualization of your router NFA.

To generate one for your app, simply run Rails.application.routes.router.visualizer from your Rails console and save the returned string into an html file. (You will need the dot command-line tool for this – OS X users can get it from homebrew with brew install graphviz. )

Oh, is it not working? I forgot to mention that this tool is broken on Rails 5 by an internal refactor. Don’t worry though, because Seth fixed it for us in this pull request, which would come out with the next 5.0 patch release. If you are impatient, you could try it out by running the 5-0-stable branch.

Before you build your next billion-dollar startup with this awesome tool, please note that this is an undocumented ( private! ) API, and as you can see, could break unexpectedly between versions (or go away entirely).

While it’s definitely not Production Grade™ software, it’s still very useful for learning and debugging purposes. Enjoy it while it lasts!

New Stuff

Optional schema.rb Alignment

When dumping the schema, Rails tries to align things vertically for readability. However, this could result in a bigger diff than you would like when making changes to an existing table. With this PR, you now have an option to turn that off!

Controller Tests Now Supports as Option

While integration tests are strongly preferred over controller tests going forward, this PR allows you to simulate a request content type in controller tests using the same as: :json (or as: :xml , and so on) option. 

retry_on Gets A Job

Active Job’s retry_on API can now access to the job instance that failed, in addition to the exception object.

Make touch_later Respects no_touching

The no_touching API now composes correctly with touch_later as you would expect.

Query With Arrays and Ranges

With this PR, you will be able to pass an Array or Range object to where(some_column: …) when querying an array/range column, assuming your database supports those column types.

Fix Upgrade Task Documentation

This is a periodic PSA that when it comes to upgrading Rails apps, the update task is going to be your friend. In Rails 5, this command has been renamed to rails app:update , whereas when upgrading to Rails 4.2 and below, you would want to use rake rails:update instead.

See the upgrade guide for more details.

In Case You Missed It…

Active Job Defaults To Async Adapter

In case you missed it, Active Job in Rails 5 defaults to using the “async” adapter for jobs processing (the previous default was the “inline” adapter). The documentation has been updated to reflect that change.

Wrapping Up

That’s it from This Week in Rails! As always, there were a lot more changes than we have room for. If you are interested, definitely go check them out yourself!

Until next week!

This Week in Rails: params encoding, better logging and more!

Hello! This is Roque covering latest events from the Rails community. Like in Rio, our week was busy with plenty of amazing participants #Rio2016 🇧🇷

Security releases!

New Rails versions are released with many important security fixes. If you have not done already, do not drop the ball and upgrade as soon as possible.

This Week’s Rails Contributors

This week 29 code athletes contributed to Rails. We also got 1 first time contributor. Welcome aboard the Rails Games!

Allow specifying encoding of parameters by action

Controllers can list the parameters with parameter_encoding, providing the action and the encoding type.
This allows parameters in the same request to have particular encoding types.

Fixed

Fix thread_mattr_accessor class leaking

thread_mattr_accessor was sharing the variable with superclasses and subclasses. Setting the variable in one would compromise the other.

Fix the Accept header overwritten issue in integration tests

XHR integration tests were overwriting the Accept header and creating inconsistency with HTTP_ACCEPT.

Improved

Better logging of cached partial renders

A while ago, DHH suggested an improvement to better log cached partial renders. It looks pretty clean!

Show error message when Rails runner fails

The Rails runner will now give you a hint of what is going on whenever it fails with an exception.

Wrapping Up

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

Until next week!

This Week in Rails: New APIs, bug fixes, #Rio2016 🇧🇷

Hello! This is Andy bringing you another week’s worth of highlights from Rails. Today also marks the official start of the #Rio2016 Olympic Games 🇧🇷 . New events this time around include golf, sevens rugby and kitesurfing, so check those out!

Rails Contributors

This week we’d like to thank 18 contributors to Rails and extend a welcome to this week’s only first-time contributor!

New exception handling APIs for ActiveJob

New APIs retry_on and discard_on have been added to ActiveJob. These provide hooks for a job class to perform some additional functionality when exceptions occur. The PR for this feature has some nice discussion, check it out!

New ActiveRecord transaction error classes

ActiveRecord can now distinguish between serialization failures and deadlocks. A more specific error in the case of deadlocks is now returned where supported (currently only PostgreSQL). Check the PR for an analysis of other database adapters and the latest code as the class names may have changed.

Fixed

Activesupport::Duration inconsistencies around daylight saving time

Since this commit from December, “week” durations are no longer converted to days. This means we need to add :weeks to the parts that ActiveSupport::TimeWithZone will consider being of variable duration to take account of DST transitions.

Improved

YAML Parameters backwards compatibility

This change provides backwards compatibility for Rails 4.2 based on YAML serialization changes made in Rails 5.

Wrapping Up

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

Until next week!

🔎 This Week in Rails: Much investigations, such bug fixes! 🔍

This is detective  🕵  Prathamesh reporting from the secret chambers of Rails.

We were busy investigating many  🐛🐛🐛🐛🐛  this week and I am happy to announce that we have successfully solved many mysterious cases 💪

Rails Contributors

Great 🔍 work by 22 detectives who solved mysterious cases this week. Also welcome to 4 new  🕵  in our growing list of contributors!

Ruby/Rails applications not vulnerable to HTTProxy security issue

The Phusion team found out that Ruby, Rails and Rack applications are not affected by the recent security issue related to HTTProxy. Great  🕵  investigation!

Fixed

Use already loaded records in the finder methods

If the records of the finder queries are already loaded, then Rails will use them instead of querying again.

Correctly return associated_table when associated_with? is true

This fixes an issue related to has and belongs to many associations failing when the association name and table name are the same.

Remove circular join references in join_dependency

This fixes a stack level too deep crash when a circular join on the same table is used with the current scope.

Correct the behavior of virtual attributes on models loaded from the database

Before this change, virtual attributes not backed by the database would throw an error unless explicitly initialized. This change fixes it and also cleans up the implementation for virtual attributes. 

Improved

Reset rack.input when the environment is scrubbed for the next request

Before this change, parameters sent via post requests would leak across requests in the Action Controller tests. This change prevents that by cleaning rack.input at the end of the request scrubbing.

Changed partial rendering to allow collections which don’t implement to_ary

This change allows collections which do not implement to_ary also to be used for rendering partials. It allows instances of Enumerator or Enumerable to be used for rendering partials.

Wrapping Up

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

Until next week!  🕵 🔍 💪

🚀 This Week in Rails: 2x String#blank? perf, assert_changes and more! 🚀

Hello from Vipul.

This was one busy week, with many changes landing on master.
We had lots of performance improvements, bug fixes, new additions and enhancements.

And here I thought everyone was just playing Pokemon Go now. 

Kasper joins Rails core!

That’s right Kasper gets himself a cartoon face!

Kasper has helped make countless changes and helped others make them as well.

He’s continued to making substantial, individual contributions, like the new partial collection caching scheme, wildcard template dependencies, and big improvements to the test runner.

This Week’s Rails Contributors

This week saw contributions from 30 fabulous people. 2 of those had a commit merged into Rails for the very first time.

A big thank you to you all! ❤️ If you fancy seeing yourself up there next week, why not take a peek at the list of current issues? Improvements to the documentation can also be a great place to start!

2x performance boost for String#blank? in Ruby 2.4!

String#blank? now uses Regex#match? following the backwards compatible addition of Regex#match? that was introduced.

This helps to get upto 2x the performance with new Regex improvements on Ruby 2.4!

Introduce assert_changes and assert_no_changes

ActiveSupport::TestCase was augmented to complement assert_difference with a more more general usage.

With this handy comparison, we can now do something like-

user = User.start_registration
assert_changes ‘user.token’, from: nil, to: /\w{​32}​/ do
  user.finish_registration
end

to encapsulate the state changes, before and after an operation.

New

Bring back support for callable cache key when rendering collection

Support for custom callable cache key was added back to view caching. This allows us to do something like

<%= render partial: ‘projects/project’, collection: @projects, cached: -> project {​ [project, current_user] }​ %>

and pass a key based on a callable block, which allows us to depend on cache’s and cache expiration based on result of the call. In the above case, the cache will be expired with changes to project and current_user objects.

Add exists? and update_all to CollectionProxy to respect an association scope

This change added exists? and update_all to CollectionProxy to respect an association scope.

This was causing issues in newest version of Rails whenever update_all or exists? were called on a collection object like user.references.update_all(…).

Fixed

Fix bug in ActiveRecord TimeZoneConverter#set_time_zone_without_conversion

Before this change, multi-parameter attributes conversion with invalid params caused issue, when AR’s time_zone_aware_attributes was enabled, since that caused an invalid conversion. 

The new change, now tries conversion only when a valid value is available for safe-conversion.

Fix calling merge method as the first occurrence in a scope

Previously calling merge as the first method to build up a scope used to lead to errors-

scope :unsafe_chaining, -> {​ merge(Comment.newest) }​ #=> NoMethodError:

This change now allows us to overcome this and build up scopes like-

scope :_chaining, ->{​merge(Comment.newest).joins(:comments) }​ # => OK_

Improved

Allow MessageEncryptor to take advantage of authenticated encryption modes

This change allow MessageEncryptor to now support authenticated encryption modes.

AEAD modes like aes-256-gcm provide both confidentiality and data authenticity, eliminating the need to use MessageVerifier to check if the encrypted data has been tampered with. This speeds up encryption/decryption and results in shorter cipher text.

Setup default session store internally, and no longer through an initializer

This change removes creation of the config/initializers/session_store.rb to define session store via initializer and sets up default session store internally.

By default the session store will be set to cookie store with application name as session key.

Wrappin’ 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: Y U have not updated to Rails 5 yet?!

Hello from Claudio.

This week saw some small fixes applied to Rails 5. Nothing major. Nothing that should stop you from upgrading all your apps from Rails 4.2 to Rails 5. So get onboard! You can do it!

Rails 4.2.7 and 4.1.16 have been released!

Check the blog post for links to all the CHANGELOGs. As Rails 5 was released, this is probably going to be the last release of Rails 4.1. Please take some time to upgrade your application to Rails 4.2 or Rails 5.

This week’s Rails contributors

32 people contributed to Rails this week, including 6 first-timers. Congratulations! Don’t hesitate to check all the changes merged into master this week. 

New

Add support for limits in batch processing

Active Record’s batch processing methods now support limit, so you can write statements like Post.limit(10_000).find_each { ​|post| … }​.

Fixed

Fix AR::to_param to maximize content

The documentation states that AR::to_param should truncate values longer than 20 characters by words. This commit enforces this behavior, using as many characters as possible to maximize the information included in the URL.

AS::Duration to serialize empty values correctly

ActiveSupport::Duration::ISO8601Serializer will not fail when asked to serialize zero-length durations such as ActiveSupport::Duration.parse(0.minutes.iso8601).

AS::TimeZone#strptime to raise the correct error

Trying to parse an invalid date such as in strptime('1999-12-31', '%Y/%m/%d') will now raise ArgumentError rather than the confusing NoMethodError: undefined method empty?.

Check request.path_parameters encoding when they’re set in env

The encoding of path parameters is now checked earlier in the dispatch process so that routes that go directly to a Rack app, or skip controller instantiation, don’t have to defend themselves against non-UTF8 characters.

Improved

Speed up RDoc generation

Every commit to rails/master automatically updates the Rails docs. The RDoc generation has gotten faster by only including files that contain changes since the last generation.

Wrappin’ Up

Repeat after me: “Next week I will upgrade all my projects to Rails 5.”

💬 “Next week I will upgrade all my projects to Rails 5” 💬

I hope you do! And finally, if you happen to travel to sunny California this summer, come say hi at the Los Angeles Ruby meetup. 🌇😎🏄

–Claudio

🌵 This Wild Week in Rails 🌵: Rails 4.2.7/4.1.16, new tag helpers syntax and more!

Hola desperados!

Jon (aka Juan el bandido) here saying “Howdy” from the Navarro desert near Pamplona 🇪🇸 to bring you outlaws a back-slappin’ sagebrush issue of This Wild Week in Rails 🌵.

We’ll be covering a selection of the past 2 weeks’ commits. That’s a dadgummit lotta ground to cover, so pack a saddlebag o’ water, watch out fer rattlesnakes, and dontcha hesitate to click through to the pull requests for more info!

Giddyup!

This Week’s Rails Contributors

Let rip some proper hootin’ & hollerin’ fer these 38 heroic wranglerswho contributed to Rails this week, including 8 first-timers! Check out the current issues and the contributing guide if ye’d like to join ‘em!

Rails 4.2.7.rc1 and 4.1.16.rc1 released, gold fever ensues

These two release candidates hit the trail this week. The final release of Rails 4.1.16 should be on its way shortly if no regressions are found. It will probably be the last release of Rails 4.1, so please take some time soon to upgrade your application to Rails 4.2 or Rails 5.

New syntax for Action View tag helpers

Building on an implementation proposal by DHH, new syntactical sugar has been introduced for tag helpers that supports HTML5 markup by default and avoids positional parameters. See the PR for details and code examples as well as #25289 for the groundwork and discussion.

Updated and improved Rails Guides

Many vital documentation contributions were made these past 2 weeks, including completion of the Rails Testing Guide (yeehaw!) and updates for Rails 5.

Improved

Cleaner, simpler stack traces

Scheduled for Rails 5.1, this commit aims to clean up noisy stack traces and log only the traces relevant to the developer. The discussion in the PR and in #25343 is worth reading.

Update Action View tag helpers attributes

This commit brings the boolean attributes for the Action View tag helpers up to date with the current w3.org spec, while dropping autobuffer in favor of preload and removing pubdate.

Raise on nested time travel helpers

Nested time travel calls in tests can lead to confusion in time stubbing. To discourage this practice, Rails now raises on nested travel and travel_to time helper calls.

Fixed

Use correct timezone when parsing dates in json

Time specified in ISO 8601 format without Z should be parsed as local time, yet until now it was treated as UTC. This commit fixes the problem by parsing time using the timezone specified in the application config. Additionally, YYYY-MM-DD format is now parsed as Date , not DateTime as it was until now.

Ported to Rails 5-0-stable since this is a potential breaking change.

Routes using as option now work with GET requests

This fix adds the option to the end of the URL path rather than the query params. The PR discussion contains an example of checking impact on performance and working around it. Backported to 5-0-stable.

Don’t reap reassigned connections

This fix ensures that concurrent invocations of the connection reaper cannot allocate the same connection to two threads. Backported to 5-0-stable.

Fix race condition with websocket stream writes

ActionCable::Connection::Stream now safeguards against concurrent writes to a websocket connection from multiple threads. Backported to 5-0-stable.

Close hijacked I/O socket after use

ActionCable::Connection::Stream now properly closes hijacked sockets when the connection was shut down. Backported to 5-0-stable.

Fix adding implicitly-rendered template digests to ETags

Modifying an implicitly-rendered template for a controller action using fresh_when or stale? now correctly results in a new ETag value.

Fix Type::Date#serialize to consistently return a date object

Type::Date#serialize now properly casts values to date objects when making where and find queries on a date field. Backported to 5-0-stable.

New

New middleware for debugging reloading/executing deadlocks

Backported to 5-0-stable, this PR adds new ActionDispatch::DebugLocks middleware that can be used to diagnose deadlocks in the autoload interlock.

Enable using rake notes with other directories

Developers and gems can now use rake notes to extract notes from other directories (like /spec) by registering them with the SourceAnnotationExtractor.

Wrappin’ Up, Ye Saddle Bums

Luddy Mussy, ah’m all sewn up! That’s all for This Wild Week in Rails 🌵. Der wuz more improvements than we had room to cover here, so doncher hesitate to check ‘em out!

‘Til next week, amigos!

This Week In Rails: Rails 5 is out with new guides and more!

Hello open sourcerer!

Here’s Kasper rushing straight from the bullpen to the printers to report: Slow week, but we’ll get through it.

Just kidding! Rails 5 is here.

In fact, to really underline the magnitude of this achievement please play this music while you read.

Rails 5 is here!

After a period of betas Rails 5.0 has now been released. The headline features are Action Cable and a mode primed for API-only apps.

There are also loads of other goodies which we’re covered here before. Check out our archives or comb through the 9999 commits themselves.

Guides updated for Rails 5

If you’d like a more high level overview there’s also new guides ready.

You can find tips on upgrading, there’s a new version of the testing guide — and there are the full release notes, which has a lot of details.

Rails 5: made by you and me

Rails 5 wouldn’t be possible without the 948 people who put in free time to help make these releases happen. A roaring thank you goes out to every contributor big and small. ❤️

(Here’s what happened just this week.)

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: 5.0.0.rc2 release, bugfixes, and more!

Hello everyone! This is Greg bringing latest news from the Rails community.

This week’s Rails Contributors

22 great people helped this week to move the Rails framework forward! If you want to join these folks, have a look at the issues list.

Rails 5.0.0.rc2 release!

Rails 5 RC2 has been released with a lot of bug fixes and polishing. We are one step closer to the final release!

Fixed

Fix rails/info routes for apps with globbing route

The /rails/info routes were inaccessible in apps with a catch-all route, as they were being appended after the globbing route and would never be matched.

Fix db:structure:load silent failure on PostgresSQL error

The db:structure:load  task silently failed if there was any SQL error, but with this commit, now it will report the error.

Improved

Improved db:structure:dump

To avoid unnecessary diffs in the db structure dump, the –skip-comments flag is passed to the mysqldump  command from now on.

Changed

datetime_field change

The datetime_tag helper now generates an input tag with the type of datetime-local.

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: smarter file update checker, testable custom queue adapters and more!

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

This Week’s Rails Contributors

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

Fixed

Fix digesting non-HTML templates when name conflicts

This fixes a scenario that caused incorrect template digests for */* requests that render non-HTML (e.g. JSON) templates. The HTML template was being used to compute the cache instead of the requested type.

Prevent the FinderMethods#exists? from raising RangeError

It will return a boolean value instead of going 💥 when value is out range.

Improved

The file update checker will boot once per process

The checker will now play nice with multi-threaded web servers like Puma. Please read the pull request for more details.

Custom queue adapters will now work with Active Job tests

If you have a custom queue adapter for Active Job, you can override the method queue_adapter_for_test in your tests to take advantage of the test helpers provided.

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: quieter loggers, faster delegators, and smarter defaults!

Ahoy hoy! Tim (aka Godfrey[9]) here bringing you all the latest from the Rails community. It’s been yet another killer week of activity as we continue to refine Rails 5 ahead of its upcoming launch 🚀. Don’t touch that dial - it’s gonna be a helluva show!

This Week’s Rails Contributors

This week saw contributions from 26 fabulous people. 3 of those had a commit merged into Rails for the very first time. A big thank you to you all! ❤️

If you fancy seeing yourself up there next week, why not take a peek at the list of current issues? Improvements to the documentation can also be a great place to start!

Rails 5: The Tour

Last week brought us an updated look at Rails by none other than DHH himself. The video offers a whirlwind tour of some of the most powerful features of the framework for newcomers in a tutorial that gets a blog set up in around 20 minutes. It also offers something for those looking to integrate newer features into their existing Ruby on Rails applications.

Fixed

#send_file can terminate the callback cycle when used in a before_action

A recent regression caused #send_file to fail to halt the request cycle when used in a before_action. This is because the callback terminator checks for @_response_body , which is no longer set by #send_file. This fix updated to use #performed? instead.

Broadcasting properly delegates #silence to all logs

If you use broadcasting to send messages to multiple loggers, you may have found that it does not silence all of them when told to do so. The fix updated to properly delegate #silence to all.

Improved

Delegation gets a boost by leveraging Kernel#caller_locations

Kernel#caller_locations was introduced in MRI 2.0, and outperforms Kernel#caller in Module#delegate by around 10%. For the author this resulted in a faster boot time.

Framework defaults file gets a spring clean

The new_framework_defaults file got a spruce this week, and documentation was updated to include better advice for upgrading to the new defaults from older apps. 

The change also utilizes the update flag in several places to provide better messages catered for those only on the upgrade path.

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: An Apology, Initializer Changes, and More!

Hey, team. Todd here, bringing you another edition of This Week in Rails! Due to a scheduling mishap, we missed an issue last week - we won’t cover it here, but I encourage you to check out the repo activity during that period.

Anyway, let’s get to the exciting stuff from this week!

This Week in Rails – Now in Korean!

First off, a very special thanks to Suhan Lee for translating our newsletter into Korean! He’s going to try to translate each newsletter going forward. If you’re interested in providing more translations, feel free to get in touch with Godfrey.

This Week’s Contributors

We had 25 of you lovely individuals contribute code and documentation to Rails this week. You all rock! Keep the contributions coming!

New Stuff

Collapse Default Initializers Into a Single File

A late addition to Rails 5: default Rails initializers will no longer live in their own files. Instead, a new new_framework_defaults.rb file will be included in new apps generated with Rails 5.

Improved

Add WebSocket and logger Configuration Options for Action Cable

You can now configure your own WebSocket and logger options when using Action Cable.

Slim Down Active Record YAML Dumps

This patch decreases the size of model dumps to YAML - in some cases by a whopping 80%!

Fixed

Fixed Issue Chaining #exists? to #includes

Sean was able to fix an issue where chaining #exists? on #includes would raise an error. It sounds like there’s more work to do here yet, so I encourage giving the commit message a look-see.

ActiveRecord::Base#hash Should Differ Between Classes

Previously, there was an issue where it was possible to have collisions if #hash was called on two different models with the same ID. This is now fixed on master.

Remove OpenSSL Deprecation Warnings

This patch fixes deprecation warnings caused by the OpenSSL::Cipher::Cipher namespace changing to simply OpenSSL::Cipher.

Wrapping Up

That’s a wrap for This Week in Rails! There were plenty of other things going on, so feel free to jump in and check them out yourself!

See you next week!

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!

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!

This week in Rails: stable releases, `Parameters#dig` and moar awesome fixes

Hey there!

This is Washington with the latest news from Rails!

This week’s Rails contributors

Again we start pointing to the 40 people who took some time to improve the framework this week!

Rails 4.2.6 and 4.1.15 have been released

After a round of release candidates here goes the latest stable releases. Hopefully a quite easy upgrade if you’ve been following the latest security patches.

New Stuff

Introduced ActionController::Parameters#dig

Similar to Hash#dig, this easter egg for Ruby 2.3.0 users was introduced this week and should land with Rails 5.

Improved

Symmetric job payload across JSON dump/load

One last piece of a non-native JSON data type, aka Ruby symbols, was normalized so that one can make successful run time checks.

Default rendering behavior on respond_to collector

This is done so that actions using respond_to blocks go hand in hand with Rails 5 default :no_content response for missing templates.

Prevent Marshal.load from looping infinitely

Improved compatibility for marshalled objects between Rails versions, e.g. Rails 4.0.x and 4.2.x

Execute default_scope within the scope of subclass

Give a proper context to queries involving a default_scope triggered from a subclass of ActiveRecord#Base.abstract_class.

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: Rails 4.2.6.rc1 and 4.1.15.rc1, AS::Executor and AS::Reloader APIs and more!

Hi All!

This is Vipul bringing you the latest news from Rails!

This week’s Rails contributors

This week 48 contributors helped to move Rails forward! Want to be one of them? Look at the issues list and make a contribution!

Rails 4.2.6.rc1 and 4.1.15.rc1 have been released

Rails 4.2.6.rc1 and 4.1.15.rc1 have been released! If no regressions are found expect the final release around March 4, 2016.

Publish AS::Executor and AS::Reloader APIs

These both allow external code to run blocks of user code to do “work” at a similar unit size to a web request without needing to get intimate with Action Dispatch.

This change is intended to allow interested callers (Sidekiq, Action Cable), to just do:

Rails.application.reloader.wrap do
  # run some user code
end

and Rails will take care of the interlock, code reloading, returning Active Record connections to the pool, and anything else that might be relevant. Exciting, if you have ever been stung by concurrent processing in jobs, etc.

New Stuff

Rails now defaults to Puma 3

With related changes from Puma, Puma 3.0 and up introduced compatibility to read from config/puma.rb when booting from the command $ rails server. Rails now depends on Puma 3.0, so that support for config/puma.rb comes out of the box.

Add exclude option to SSL middleware

The force_ssl option redirects each request to HTTPS. This change now allows redirection to be constrained to only whitelisted requests with exclude:

config.ssl_options = { redirect: { exclude: -> request { request.path !~ /healthcheck/ } } }

Improved

Generate config/spring.rb in new applications

This change makes the application generator create a new file config/spring.rb, which tells Spring to watch additional common files, for example .ruby-version. This file can then be edited to suit each application.

Added log “Rendering …”, when starting to render a template

This change added log “Rendering …”, when starting to render a template, to log that we have started to render something, at the very beginning.

This helps to easily identify queries called from controller vs views.

Deprecations

Deprecate :controller and :action path parameters in routes

Allowing :controller and :action values to be specified via the path in config/routes.rb has been an underlying cause of a number of issues in Rails that have resulted in security releases. In light of this it’s better that controllers and actions are explicitly whitelisted rather than trying to blacklist or sanitize bad values. This change deprecates passing these options in routes.

Deprecate {insert|update|delete}_sql in DatabaseStatements

This change deprecates {insert|update|delete}_sql in ActiveRecord::ConnectionAdapters::DatabaseStatements in favor of {insert|update|delete} public methods. Originally, {insert|update|delete}_sql were protected methods, and were not intended for external use.

Deprecate Module.local_constants

Module.local_constants has now been deprecated. After Ruby 1.9 (and since Rails 5 supports Ruby 2.2+), we can easily get the constants that have been defined locally by Module.constants(false). Hence, Module.local_constants is no more necessary.

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: Turbolinks 5, Rails 5.0.0.beta3 and more!

####

Hello, this is Greg bringing you the latest news about the Rails framework!

This week’s Rails contributors

This week 51 great developer helped to move Rails forward! Want to be one of them? Look at the issues list and make a contribution!

Rails 5.0.0.beta3 has been released

Rails 5 is getting closer to the release candidate. The new beta brings many improvements and fixes.

New Stuff

This commit made Rails compatible with Turbolinks 5 and master uses the beta release of Turbolinks 5 now.

rake test now respects TESTOPTS

With this change, we can now pass options to minitest via the TESTOPTS environment variable.

Fixed

Fixed primary key uniqueness issue

This commit reverted some earlier changes which caused an issue with the uniqueness validation of a primary key field, when the primary key field is called something other than id.

Fixed CSRF issue with button_to tag

There was an issue with the CSRF token generated when button_to was called with the delete method, but it is all fixed now!

Improved

Improved Action Cable reconnection reliability

This pull request improved the Action Cable reconnections by treating closing state as closed and by calling ActionCable.ConnectionMonitor#connected() on the client side upon successful connection. It also introduced client side logging to make debugging easier.

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: RailsConf program, on_weekday? and more!

Hello, this is Godfrey and Prathamesh bringing you the latest developments from Rails!

RailsConf 2016 program announced

The conference is looking pretty awesome, with a good mix of talks on various topics. I hope you are as excited as I am!

This week’s Rails contributors

This week, we have recorded 136 commits from 37 contributors (including 8 first-time contributors)! Thank you for making Rails better for everyone!

New Stuff

#on_weekday? method to Date, Time, and DateTime

Along with #on_weekend?, you can now easily find out if a certain day falls on a weekday (M-F). The question is, do you really want to know?

Fixed

Fix incorrect behavior with unsubscribing to channels

Saying goodbye is certainly hard, but having to listen for one might just be worse. Luckily for us, all of these are abstracted deep inside Action Cable, so we will never have to go through that ourselves.

Improved

Inject Rails configurations through Railtie

Dependency injection might not be a virtue, but in this case, it certainly helps keeping things neatly isolated from each other.

Tagged errors in logs

A while ago, tagged logging became the default on production on Rails 5. Now the tags are included in the logs for errors too!

Automatically reset ActionMailer::Base.deliveries in integration tests

With this patch, Rails 5 will automatically clear the ActionMailer::Base.deliveries array in between your integration tests.

Support nested params in button_to helper

We can now pass nested hashes or arrays to button_to helpers’s params option.

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!

Ruby on Rails, with love since 2005

#

Happy Valentine’s Day weekend!

What better way to show your love for Rails than to help close the last few issues pending for the release candidate of Rails 5? ☺️

Claudio

This week’s contributors

Thanks to the 41 people who loved Rails this week by contributing to its source code. A special kiss to the 14 of you who contributed for the first time!

Guides: Using Rails for API-only Applications

You heard that Rails 5 will be able to generate API-only applications. Now you can learn all the details by reading this new chapter added to the Rails Guides.

The source code of turbolinks has been moved to a new GitHub organization, with plans to release more turbolinks-related libraries in the future.

New Stuff

Added numeric helper into SchemaStatements

Need to add a numeric column to a database table? You can now use t.numeric :foo which is a lovely alias of t.decimal :foo.

Add as to encode a request as a specific mime type

You can now test a JSON POST request with post articles_path, as: :json rather than adding helpers like post_json. And you can also test the response as parsed JSON with parsed_body.

Fixed

Fix performance regression in Active Record

RubyBench analyzes every commit made to rails/rails so performance regressions can be rapidly discovered… and fixed!

Improved

Speed up string xor operation and reduce object allocations

We love commits like this one which improve the performance of Rails and use benchmark/ips to measure their impact.

Set database poolsize via RAILS_MAX_THREADS

The environment variable introduced in config/puma.rb is now reused in the database configuration to avoid connection timeout errors.

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 peek at the changes yourself.

Until next time!

Rails 5 beta 2, RailsConf 2016 registration and more!

####

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

Rails 5.0.0.beta2 has been released!

Please give Rails 5.0 a try on your app. Spotting bugs and upgrade issues ahead helps big releases like this.

This week’s contributors

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

RailsConf 2016 registration is open

All aboard! The next train is leaving to Kansas City. Don’t miss it! Tickets sales ends April 3rd.

Rails 5 only supports PostgreSQL 9.1+

Rails 5 will only support versions of PostgreSQL greater than or equal to 9.1. Older versions are no longer supported by the PostgreSQL team. You can read more on their official page.

New Stuff

Add default Puma config and option to skip it

A default config has been added for Puma. It sets the default Puma thread count to 5 to mach Active Record’s default, and prevent connection timeout errors.
Puma can now be skipped when generating new apps with the --skip-puma option.

Rails command now runs Rake tasks in Engines

Just like in Rails apps, it is now possible to use the rails command to execute rake tasks in Engines.

Fixed

Fix corrupt transaction state caused by before_commit exceptions

This makes Active Record aware that a database was rolled back when a before_commit callback raises an exception.
Before, Active Record would think the connection was active, and fail.

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 peek at the changes yourself.

Until next time!

This week in Rails: Security releases and getting closer to Rails 5 RC

This is Prathamesh bringing the latest news from this eventful week of security releases and getting closer to Rails 5 RC.

Security releases!

New Rails versions are released with many important security fixes. If you have not done already, upgrade as soon as possible.

This weeks contributors

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

New Stuff

Drop Action Cable dependency on EventMachine

Action Cable no longer depends on EventMachine. A lot of work is done to make sure that this change works properly. Hat tip to Matthew Draper for all the great work!

New welcome page for Rails 5

Do you remember the old Welcome aboard page? It’s now replaced by Yay! You are on Rails! The welcome page got a big facelift in Rails 5, gone are the needless links and extra data. It’s compact and mentions only relevant things.

Generate index for referenced columns by default

Rails will now generate indexes for referenced columns by default without mentioning it in migrations. That’s what we want in 90% of the cases anyways!

Fixed

Issues with ActiveRecord::Relation#cache_key fixed

Lots of corner cases with using cache_key with loaded and unloaded collections and with selecting specific columns are fixed.

Fix issue with has_many: through STI association

An issue with incorrect source_type getting used in case of has_many: through associations with STI models is fixed.

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 peek at the changes yourself.

Until next time!

This Week In Rails: Doctrine, Weak ETags, Cabled Postgres and more!

Hey passengers!

Have your luggage ready and get those ticket stubs out, a new issue is just about to roll in to the station. Godfrey and Kasper are co-conducting this beast of steel — eh, newsletter with Rails news, we mean.

Hop aboard before we roll off, and start choo-chooing toward…

Hey, does that sign say “Tracks End Here”?

Fresh off the tracks, a new Rails site!

Ahead of the coming major release of Rails, we got a new website and logo and… doctrine?

Yes! See, Rails has been going strong for over 10 years, the Rails Doctrine just captures that magic and spells it out. Thus Rails is ready to roll on for the next decade. The blog post dishes on the new design’s backstory.

P.S. The Rails core team got some awesome new pictures too!

This weeks Rails Contributors

This week 41 people contributed managed to rivet themselves away from the shiny new pixels above and buckle down some contributions. Kudos to you folks 😁

New Stuff

Action Cable: Postgres pubsub can sub for Redis

Action Cable uses Redis to handle publishing and subscribing, but this week Postgres became a proper pubsub’er and is swappable with Redis.

SQL expressions as a column’s default value

With this pull request, you will be able to use a SQL expression (such as a SQL function) as the default value for any column type!

Fixed

Weaker ETags makes HTTP caches stronger

HTTP ETags help cut bandwidth by sending along a tag that the server could use to validate the cached content.

Rails supports it out-of-the-box but issues “strong” ETags, which has stronger cachability implications than Rails can guarantee.

Not anymore! In Rails 5, Rails now correctly issue “weak” ETags — matching Rack::ETag’s behavior.

Improved

Removed Action Cable’s celluloid dependency

Action Cable’s dependency on the celluloid gem has been removed by using the thread pool from concurrent-ruby (which Rails already uses). While temporarily reverted it was reintroduced this week.

Better configuration documentation for Action Cable

Now rejiggered: the Action Cable documentation on how to configure the library has been clarified and better highlights how useful some methods are.

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 peek at the changes yourself.

Until next time!

New Rails identity

It’s been 10 years since we last updated the Rails identity, so with Rails 5 just around the corner, we thought it was finally time for a fresh look for a new day. This is it! We have a brand new logo, a brand new site design, and lots of lovely new illustrations.

We can thank Basecamp designer Jamie Dihiansan for the awesome new look. The brief was that Rails shouldn’t feel slick. It should be warm, approachable, and welcoming. Rails is in a different place from where it was in 2004. We aren’t courting cutting-edge early adopters, so we can lay off the gradients. Rails is now for everyone and our site should reflect that.

The Rails Doctrine

In concert with the new look, I wrote the eight major tenets of The Rails Doctrine. It’s still a bit of a work in progress, but please do give it a read if you want to understand deeper the values and practices that underpin us as a framework and a community.

A new video is coming

I was going to record a new video for the homepage, but since we’re just on the cusp on some changes to Rails 5 that’ll change things a bit, I’m holding off until beta2 (which should be out shortly). In the mean time, you can enjoy the introduction to Action Cable. But rest assured that it’ll soon be replaced by a new, proper introduction.

Hope you all enjoy the new look. Now let’s ship Rails 5!

This week in Rails: Happy New Year!

Happy New Year! Welcome to the first 2016 issue of This week in Rails.

I’m Andy, and before diving in to contributions from this week, let’s briefly recap some stats from 2015. Our 12 editors released 50 issues summarizing over 6500 commits to Rails! Each issue is now being sent to over 4300 subscribers.

What a great year! To celebrate, sweep up some confetti laying around from last weekend, toss it in the air, and sing some bars of Auld Lang Syne.

This Week’s Rails Contributors

79 people contributed to Rails since the last issue on December 18, 2015! Check out the list of issues if you’d like to help out as well.

RailsConf 2016 CFP deadline

Interested in speaking at RailsConf 2016 in Kansas City? Call for proposals closes January 15th, 2016, 11:59pm CST! You’ve got 1 week!

New Stuff

Security: Per-form CSRF tokens

Changes brought upstream from GitHub, related to Content Security Policy (CSP) and securing forms. Check out the links in the PR to learn more.

Default new apps to tag logs with request_id

The :request_id log tag ensures that each request is tagged with a unique identifier.

Short-hand methods for types in MySQL

This change adds short-hand methods like tinyblob and mediumblob for text and blob types when using MySQL.

Fixed

Don’t output to STDOUT twice

Stops printing messages twice with rails console or rails server and a logger set to output to STDOUT.

Faster

Replace x.times.map{} with Array.new(x){}

Small performance improvement supported with a benchmark. Check out the results.

Wrapping Up

That’s all for This week in Rails. As always, there are many more changes than we have room to cover here, but feel free to check them out yourself.

Until next time!

This week in Rails: Rails 5 - The Beta Awakens

I hear you’re looking for a pilot. Name’s Todd Solo, captain of This Week in Rails. She may not look like much, but this bucket of bolts did the Kessel Run in less than twelve parsecs. She’s more than capable of smuggling all of the latest Rails intelligence to you.

I’ve got a very Special Edition™ for you this week - we’re celebrating the release of the very first beta of Rails 5! We’re going to be covering all of the big additions made since the release of Rails 4.2 in this issue. Don’t worry - no Bothans died to bring you this information.

This Release’s Contributors

We had 790 scruffy-looking nerf herders contribute to this release. That’s over 7000 commits in a little over a year! Give all of these folks a big round of applause!

Rails 5 Only Supports Ruby 2.2.2+

This is important - Rails 5 will only support versions of Ruby greater than 2.2.2. Ruby 2.2 introduces a number of new features and performance enhancements that the Rails team wants to capitalize on. You can read more about Ruby 2.2 in the release announcement.

New Stuff

Action Cable

In case you haven’t heard, Rails 5 is bringing WebSocket support along with it! Action Cable is a completely integrated solution for building WebSocket apps in Rails. Give it a spin!

Rails API

Rails 5 introduces support for API-only apps. Based on the wonderful work done by the Rails API project, you can now generate apps that strip out parts of Rails not needed for pure backends.

New Command Router

Why do you start a console with rails console, but run migrations with rake db:migrate? That doesn’t make any sense. Starting in Rails 5, many of these old rake commands can be run with rails instead.

Attributes API

Your models are getting a new attribute class method in Rails 5, allowing you to easily define a relationship between the model and a non-Active Record type. No more misusing serialize!

ApplicationRecord

Just like ApplicationController, we’re getting an ApplicationRecord model superclass in Rails 5. Now you don’t have to monkeypatch ActiveRecord::Base to add functionality!

ActiveRecord::Relation#or

A long requested feature, ActiveRecord::Relation is finally getting the #or method we’ve all wanted.

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 I highly recommend you take a peek at the release announcement and CHANGELOGs.

We’ll be back to our regularly scheduled program next week.

Until next time - may the Force be with you!

This week in Rails: GZipped Asset, API error responses and more!

Hello everyone! 🌨

This is Vipul, bringing you the latest from Rails.

P.S: Here’s something for all those at RubyKaigi 🍣. Enjoy!

This Week’s Rails Contributors

This week 26 fabulous people contributed to Rails, including 6 first-time contributors! Check out the list of issues if you’d like to help out as well.

Sprockets: Reintroduce gzip file generation

GZip file generation was taken out last year from sprockets. This change re-introduces compressed file generation and parallel file writing, which is useful for web servers that don’t support gzipping static assets. This is pretty useful if you are on a service like Heroku.

New Stuff

Introduce after_{create,update,delete}_commit callbacks

New shortcuts were added to after_commit .. on: :action.

For example, after_commit :add_to_index_later, on: :create can now be written as after_create_commit :add_to_index_later.

Improved

Rails API: Ability to return error responses in json format in development

Previously error pages are always being delivered in html pages in development mode, which is not handy when you would like to view json responses. This change adds support for viewing errors in json format. It also makes sure that when requesting resources like post/1.json, when error occurs, it returns json response based on json format in url, unlike previously used html format.

Changed the protect_from_forgery prepend default to false

protect_from_forgery will now be inserted into the callback chain at the point it is called in the application. This is useful for cases where you want to protect_from_forgery after you perform required authentication callbacks or other callbacks that are required to run after forgery protection.

If needed, you can use protect_from_forgery prepend: true to always run protect_from_forgery before others.

request_forgery_protection initializer is removed from Rails API

Usually in Rails API, you would not use protect_from_forgery, by default. The initializer to add this option- request_forgery_protection is now removed if you are creating an API.

Fixed

Subscribing to notifications while inside the instrumented section.

Previously if we tried to do

ActiveSupport::Notifications.instrument('foo') do
  ActiveSupport::Notifications.subscribe('foo') {}
end

it would create an error, because for the subscribe inside block, the dynamic subscription does not yet exist. This change make sure that subscriptions inside instrumentation get notified as well.

Add redirection path in the error message of assert_response if response is :redirect

Previously, if assert_response was checking for any non-redirect response like :success and actual response was a :redirect then, the error message displayed was like - Expected response to be a <success>. This change, now shows the redirected path in error response as - Expected response to be a <success>, but was a redirect to <http://test.host/posts/lol>

Wrapping Up

That’s all for This week in Rails. As always, there are many more changes than we have room to cover here, but feel free to check them out yourself.

Until next time!

This week in Rails: Rails command infrastructure and more!

Hello everyone!

This is Marcel, bringing you the latest news in Rails.

This Week’s Rails Contributors

This week 28 fabulous people contributed to Rails. Check out the list of issues if you’d like to see your name up there.

New Stuff

Rails Command Infrastructure

The infrastructure needed to support the movement of rake tasks to the rails command is now in place. This paves the way to make it easier to learn commands for persons new to Rails.

Improved

Allow use of minitest-rails gem with test runner

An explicit global namespace to Rails::TestUnitReporter has been added to resolve a namespace conflict between minitest-rails and Rails test runner.

Fixed

Initialized STI models are now casted to the default type

If a database default was specified for the type column used in Single Table Inheritance (STI), it did not cast new instances to default type on initialize. This is now fixed.

Replace ActionMailer::Base.respond_to? with respond_to_missing?

This simple refactor utilizes the respond_to_missing? hook introduced in Ruby 1.9. This prevents the usage of the method method from raising a NameError.

Clarify connection pool error message

The previously error message whenever all connections in the pool were used up, did not mention that.

Wrapping Up

That’s all for This week in Rails. As always, there are many more changes than we have room to cover here, but feel free to check them out yourself.

Until next time!

This week in Rails: Don't Miss Our Black Friday and Cyber Monday Deals!

Hello everyone!

This is Godfrey, bringing you the latest news deals in Rails. Have you been holding out on getting the latest copy of Rails? Don’t wait any longer as we are having our biggest sale of the year this weekend. Check out these unbelievable deals before they are gone!

🆓 RailsConf Tickets Giveaway

Limited Time Offer! Enter the RailsConf Tickets Giveaway (a.k.a. the Call For Proposals) by submitting a talk proposal! If your talk is selected, you will win a FREE admission to the conference!

Terms and conditions apply, see website for details.

🆓 Lifetime Rails Contributor Membership

As Seen On The Interwebs! Start collecting points like these 25 individuals with our award-winning rewards program. To apply for your FREE membership, simply submit a pull request to Rails. Membership never expires!

New Stuff

🆓 PostgreSQL Geometric Types Support

In-Store Only! Get FREE support for PostgreSQL data types (such as line, path and polygon) in schema.rb when you upgrade to Rails 5.

🆓 Certificate of Origin

Bonus Upgrade Offer! Rails 5 apps will be equipped with a FREE Origin header check if one is present in the request. When upgrading, existing apps will be given an option to enable the security feature at no additional cost.

Improved

🆓 Source Code Extraction

NOT A Pricing Error! If something went wrong in an AJAX request, Rails will now throw in the extracted source code in plaintext for FREE, making things easier to read in your browser’s console.

🆓 Dead Code Removal

Everything Must Go! As part of our clearance, a piece of dead code was discovered and promptly set FREE. No wonder everyone is so excited!

Fixed

🆓 Race Condition Protection

While Supplies Last! When the Evented File-System Monitoring project landed on master, a contributor pointed out a potential race condition. After ( a few attempts, we have finally arrived at a solution to FREE us from the danger!

Correction

🆓 byebug Upgrade Program

Manufacturer Rebate! In the last issue, we recommended byebug 7.0. Turns out the latest version is actually 8.2.1 (as of this week), which addressed some issue with the 7.0 release.

To compansate you for the trouble, we decided to offer a FREE byebug upgrade program for our readers. Simply change your Gemfile entry accordingly and run bundle install, and our agents will make sure the library is upgraded.

Wrapping Up

That’s all for This week in Rails. As always, there are many more changes deals than we have room to cover here, but feel free to check them out yourself.

Until next time!

This week in Rails: RailsConf 2016, frozen Hash keys, faster byebug and more!

Hi everyone! This is Godfrey bringing you the latest news from Rails.

RailsConf 2016

The RailsConf 2016 website is up! This year, we will be gathering in Kansas City from May 4 to May 6. If you would like to submit a talk, the call for proposals (CFP) is open from now until Jan 15!

This Week’s Rails Contributors

This week we have seen commits from 29 different contributors in the Rails repository, including 6 new faces!

Improved

Frozen FK Names For Association

When you use a non-frozen (i.e. mutable) string as a Hash key, Ruby would have to duplicate and freeze it in order to guarantee a stable hash key.

This is usually fine, but when that string is used to build many different hashes, the work adds up. Fortunately, we can simply freeze it upfront to avoid the repeated work.

Faster byebug

byebug 7.0 has recently been released with some major performance improvements. (See this pull request for details.) If you are using byebug for debugging, you might want to upgrade!

Speeding Up Enumerable#sum

Did you know that Enumerable#{inject,reduce} can take a symbol as its argument? Apparently, this is slightly faster too! (Note: this is different from inject(&:method) which goes through Symbol#to_proc.)

Fixed

Use Instead Of +…+ In Docs

Usually, you can use +some_word+ to switch to fixed-width fonts in Rails’ documentation. However, the parser for this rule would sometime fail in some more complex cases.

If you are not sure when to use which, be sure to check the guidelines, or just check the output locally by running rake rdoc.

Wrapping Up

That’s all for This week in Rails. As always, there are many more changes than we have room to cover here, but feel free to check them out yourself.

Until next time!

This week in Rails: new releases, exciting Rails 5 stuff and more!

Hey everyone - Tim here with another monster update with all the exciting Rails-related goings-on from this week.

Riding Rails: Snappier Development Mode in Rails 5

One of the nicest things about development mode in Rails has to be the sheer convenience of running on your latest revision on each request. This of course comes at a performance cost but is about to change: instead the filesystem will notify Rails asynchronously of any changes.

Rails 4.2.5 and 4.1.14 are here!

This week saw the release of both 4.2.5 and 4.1.14 versions of Rails. Go upgrade while they’re still hot!

This Week’s Rails Contributors

This week 33 fabulous people contributed to Rails. Check out the list of issues if you’d like to see your name up there.

New Stuff

New! days_in_year method added to Time

Now you can can call Time.days_in_year and, at the time of writing it will return 365. Call it next year and it will give you 366. Nice!

String#parameterize gets a preserve_case option

This change adds an option to Preserve-the-CASE of the string instead of casting-everything-to-lowercase when generating parameters.

Improved

Improve support for non Active Record associations on validation

Support for non-Active Record associations just got better by skipping marked_for_destruction? when going through validations if it’s not implemented, making it easier to define virtual associations.

Return a sized Enumerator from Hash#transform_values

You can now discover the size of a hash whose values have been transformed.

Fixed

Exclude views when fetching tables on all the connection adapters

This brings more consistency across the adapters where those for MySQL and SQLite would return views in addition to tables when calling #tables, where PostgreSQL would not. Now they all return tables, and no views.

Wrapping Up

That’s all for This week in Rails. As always, there are many more changes than we have room to cover here, but feel free to check them out yourself.

Until next time!

This week in Rails: new release candidates, concurrent migrations and more!

####

Hi there everyone o/

Washington here putting together another weekly Rails issue for the most awesome community.

Rails 4.2.5.rc2 and Rails 4.1.14.rc2 are out

Please take a minute or two to update your project Gemfile and run the build on the RCs. Spotting regressions now means they’re fixed in another RC rather than a new point release some month(s) away.

This Week’s Rails Contributors

As of 17h15min, UTC -3, 28 contributors made their commits to Rails master. Some of those for the very first time. Welcome!

Make migrations concurrent safe (using advisory locks)

MySQL and Postgres Active Record adapters were enhanced to avoid confusing behaviour or exceptions when running migrations on multi-instance clusters. See the issue as well for more details.

New Stuff

Add enabled flag to public_file_server settings

Good old serve_static_files is being deprecated as of Rails 5 in favor of public_file_server.enabled so we have all static asset options under the same public_file_server key.

Improved

Deprecate exception#original_exception in favor of exception#cause

Exception wrapping implementation got a bit simpler this week by using Ruby’s built in Exception#cause, available since version 2.1.

Require only necessary concurrent-ruby classes

Another concurrent-ruby bump and related load time improvements.

Don’t allow arbitrary data in :back urls

This was reported quite a while ago, but now someone stepped up to the plate and followed it through. Rails got a bit safer again, thanks to the community. ❤️

Allow passing an env to config_for

Sanity checking configuration files in other environments just got easier as well.

Wrapping Up

That’s all for This week in Rails. As always, there are many more changes than we have room to cover here, but feel free to check them out yourself.

Until next time!

This spooky week in Rails: bidirectional destroys, indexed errors and horror!

####

Beware of those,
In forests reigned by cawing crows
Who feel the fright, a stormy friday night

Your weekly Rails news, pick and choose
As we weave, this;
All Hallow’s Eve

Bet you didn’t expect to get spooked the day before Halloween, well, that’s our trick-a-trété. What? That’s what the french say — don’t ask.

This Week’s Rails Contributors

This week 42 contributors gathered in the town square, pitchforks in hand, and chased bugs out of Rails and up the mill.

That’s what mob programming is all about. I assume.

Bidirectional Destroys

Say, a USA and a USSR model employed defensive measures to destroy the other if they we’re destroyed. Before they’d keep destroying the other, now they’re more peaceful only destroying each other once. Good thing it’s a fictional example 😁

Nested attributes indexes errors by insertions

Have models with accepts_nested_attributes_for? The macro nestled out an index_errors option, so errors attach to a specific model in the submitted array.

There’s comments on the pull request, if you want to improve it further.

New Stuff

Relation gets left_outer_joins

There’s now an explicit way to do this specific join — abstracted away in includes before.
For those who want to be left out, er… join in!

Improved

Many to many relationships count a little more

While calling count on a has_and_belongs_to_many relationship was correctly counted, amping up the inclusion made threw off the count. Now you can use includes and have things counted correctly again.

Sanitizing Order

You’d have to remember to sanitize arguments you passed to order, which, if you have an example like the one in the pull request, is a pain. No more.

HashWithIndifferentAccess defaults with to_hash objects

Passing an object that responds to to_hash to HashWithIndifferentAccess.new now respects the default values and default proc if any of those are there.

One more thing™

Correction: Active Support delegation to block, args or arg

Last week, we incorrectly said this change would raise exceptions. What really happens is delegate now works with block, args or arg if those light your Jack-o’-lantern.

Wrapping Up

That’s all for This week in Rails. As always, there are many more changes than we have room to cover here, but feel free to check them out yourself.

Until next time!

Also if you really want to be scared, look yourself in the mirror! Boom, nailed it!

This week in Rails: 4000 Subscribers, File Server Headers Config and More!

####

Hello everyone! This is Roque with the latest from the Rails world.

Sending out to over 4000 subscribers!

This Week in Rails just crossed 4000 subscribers. Thanks to all subscribers and collaborators! Stay tuned!

This Week’s Rails Contributors

26 people contributed to Rails this week, including 5 first-time contributors! If you are interested in becoming a contributor, you can have a look at the issues list.

New Stuff

Create a config for file server headers

Rails now allows any static file header to be defined using the configuration option config.public_file_server.headers.
This also deprecates the former option static_cache_control that would only apply the header Cache-Control.

Force SSL in mails

The config.force_ssl option will now force mails to use the protocol https for the host setup in config.action_mailer.default_url_options.

Allow multiple root routes in same scope level

Lets say your application has multiple root endpoints depending on a constraint. You can now describe them using root entries in your config/routes.rb file instead of having to use get statements.

Improved

Make Active Record increment! and decrement! concurency safe

This will prevent issues when performing updates from different instances of a same record.

The where method will now let you know when an argument type is unsupported

where will raise ArgumentError on unsupported types.

Wrapping Up

That’s all for This week in Rails. As always, there are many more changes than we have room to cover here, but feel free to check them out yourself.

Until next time!

This week in Rails: Performance, Test Helper Changes, Mailer Preview Improvements and More!

####

tap tap

Is this thing on?

Hey, everyone! Welcome to the latest edition of This Week in Rails - your one stop shop for all the goings-on in the Rails universe. My name is Todd and I’ll be your guide. Let’s get this party started!

This Week’s Rails Contributors

We had 41 extraordinary people commit to Rails this past week, including 15 (!) newcomers. Wanna see your name on this list? Check out the list of issues.

New Stuff

Add Equality Comparison for AttributeSet

Exposes an equality comparison method (==) for comparing ActiveRecord::AttributeSet objects to each other.

Improved

Persist Format in Mailer Previews

Have you ever changed the format for a mailer preview, made a code change, and reloaded the preview only to have the desired format change back to the default? How annoying! This change utilizes JavaScript’s history.pushState to persist your desired format across refreshes. Nifty!

Performance Improvement for Active Record preload

This patch conditionally skips an expensive method call unless it’s explicitly required when calling preload on an ActiveRecord::Relation. The net benefit is an overall reduction in allocated objects and ~40% increase in speed.

Support Arrays in Active Job’s assert_enqueued_jobs

This brings Active Job’s assert_enqueued_jobs into parity with assert_performed_jobs. Specifically, the :only option now accepts Arrays.

Fixed

Fix Mounted Engine Route Regression

A regression in 4.2.3 would cause the relative_url_root and script_name to each be included in routes for mounted Engines (the expected behavior is for one, not both to be used). This patch resolves that issue on master and 4-2-stable.

Fix Test Helper Casting for Active Job

Fixes an issue where the at: argument wouldn’t be cast properly for assert_enqueued_with and assert_performed_with, causing tests to fail.

Removed

Remove pk_and_sequence_for for MySQL Adapters

pk_and_sequence_for is not used by MySQL adapters and is being removed. There won’t be a deprecation cycle for this change, so note that your implementation may break if you’re overriding this method anywhere.

Wrapping Up

That’s all for This week in Rails. As always, there are many more changes than we have room to cover here, but feel free to check them out yourself.

Until next time!

This week in Rails: Job Priorities, Fast Failing Tests and Fixtures... Oh My!

Hello everyone! This is Greg with help from Andy (welcome!) bringing you the latest news from Rails.

This weeks Rails contributors

33 people contributed to Rails this week, including 3 first-time contributors! If you are interested in becoming a contributor, have look on the issues list.

New Stuff

Add job priorities to ActiveJob

This commit allows you to set the priority for your jobs with Active Job, if your backend supports this. For more details head over to the pull request.

Fail fast reporting in test runner

If you call your test suite with --fail-fast it will abort the test run on the first failure.

Allow fixtures files to set the model class in the file itself

From now on you can set the model class in your fixture files, but set_fixture_class on your model will override it.

Fixed

Handle nested fields_for by adding indexes to record_name

This commit adds indexes to the inputs in the inner blocks of a nested fields_for, so Rails won’t raise an exception on the submission of the form.

Add a hidden field on the collection_radio_buttons

This commit fixes an issue with strong_parameters if you have a single collection_radio_button on your form and the form is submitted with no selection.

Fix parameter sanitization for query methods

With this commit the Action Controller parameters are sanitized before being passed to the Active Record query methods.

Wrapping Up

That’s all for This week in Rails. As always, there are many more changes than we have room to cover here, but feel free to check them out yourself.

Until next time!

This week in Rails: GSoC, performance improvements and bug fixes!

Hello everyone! This is Marcel with help from Andy (welcome!) bringing news from yet another week of Rails.

Google Summer of Code 2015

The fourth year of participation in Google Summer of Code 2015 is over with excellent work done in the areas of Asset Pipeline (performance and… source maps!), Web Console (browser extension), the Rails test suite (Regression Test Selection), development setup (evented file system monitoring) and internals refactoring (cookies). Special thanks to Google, mentors and students who made this all possible.

This weeks Rails contributors

46 people contributed to Rails this week, including 7 first-time contributors! If you are interested in becoming a contributor, you can have a look at the issues list.

New Stuff

Introduce Active Record ignored_columns

A use case for this would be ignoring columns that are transient. This may happen when using online schema change tools like lhm or pt-online-schema-change.

Foreign keys are now supported in create_table DSL

Not only is it more convenient to pass in the foreign_key as an option to the references method of the create_table DSL, it generates slightly more efficient SQL.

Improved

Improve the performance of Active Record save and friends

By taking advantage of internal code improvements (the MutationTracker object), Active Record’s save and similar methods have received a noteworthy performance improvement.

Change assert_difference to return the result of the yielded block

With this we can perform new assertions on the returned value without assigning it to an outer variable or otherwise wrapping subsequent assertions inside the assert_difference block.

Fixed

Fix arguments of AR::Calculations#sum

The arguments and behavior of #sum are now consistent with the other aggregate methods (count, average, minimum, and maximum) defined in ActiveRecord::Calculations.

Fix silent failure when MySQL is not running

Nothing is more frustrating than a silent failure. This fix handles an error when rake db:structure:load is run and MySQL is not installed. Previously there were no output.

Active Record: Use database precision when assigning a value to a timestamp attribute

Timestamp columns can have less precision than Ruby timestamps. This affects how a fraction of a second can be stored in the database. To fix this, the precision of the column was used when assigning a value to the timestamp attribute.

Fix ignored usages of unscoped when preloading Active Record models

Preloading an association that is using unscoped was dropping the unscoped part.

Wrapping Up

That’s all for This week in Rails. As always, there are many more changes than we have room to cover here, but feel free to check them out yourself.

Until next time!

This week in Rails: Performance, MySQL prepared statements and more!

This is Prathamesh after a long long time bringing you latest and greatest news from Rails world!

This weeks Rails contributors

37 people contributed to Rails this week, including 7 first-time contributors. If you are interested in becoming a contributor, you can have a look at the issues list.

New Stuff

Drop indexes concurrently in PostgreSQL

Now you can drop PostgreSQL indices concurrently in Rails 5, just like how you can already add indices concurrently today.

Approachable SSL handling

Remember good ‘ol config.force_ssl? You can now use it with greater control. With improvements in SSL redirect and better handling of Strict Transport Security, you will surely love this improved version of config.force_ssl.

Mult-context validations

Ever faced the need of running validations of create and update contexts both at the same time? Now you can do that by passing multiple contexts to the #valid? and #invalid? methods.

Improved

Active Record performance improvements

This week lot of work was done for improving Active Record internals by reducing object allocations, avoid creating relations when not required and so on. Kudos to @tgxworld!

Prepared statements with MySQL

Rails now supports latest version of mysql2 gem. Is this a big deal? Yes!! You can now use prepared statements using this version. Now that’s awesome!

Improve sql logging coloration

If you are using custom SQL queries with Ruby herredoc, you will be able to identify them instantly in your logs. Why? Because they will have better colors thanks to this patch.

Not just that, overall coloration of all SQL queries is improved here as well!

The cookie-handling code in Rails is one of the more complicated code in the framework, largely due to the need to support and migrate legacy cookies produced by older versions of Rails.

Kasper refactored some of those code to make it less hostile to future improvements, nice!

Fixed

Generator errors messages will be in plain English

If you have seen some weird characters showing up in error messages of rails g commands due to localization of some messages, it is now fixed!

Wrapping Up

That’s all for This week in Rails. As always, there are many more changes than we have room to cover here, but feel free to check them out yourself!

Have you been thinking about writing for us, but you’re scared of putting yourself out there? Don’t worry, you can help our editors improve their writing with thoughtful critique and general grammar policing.

You up for that? Tell Godfrey today.

This week in Rails: 4000 contributors, Rails bot abides and more!

Back away, bystander.

There’s a flame war going on, and we’d best contain it soon — the people need their Rails news!

Kasper pats flames and waters ferns in hopes we douse the mighty fires.

I’ll go brush up on campfire safety rules. Here, you read these.

Over 4000 people contributed to Rails

A little while ago we crossed 4000 contributors – that’s crazy! Remember the old days when only one person contributed to Rails? Well, I wasn’t him so I don’t. Wups!

36 people made their mark this week. If you’re new, peruse the list and join us. If you do you’ll find a new friend waiting for you.

Everybody meet Rails bot

That friend is Rails bot. Fresh off the assembly line to bring those new to Rails a welcome message and tips. You’ll even get a reviewer assigned to help move things along. Come say hi with a pull request.

Improved

Confirmation validation reduced sensitivity to case

If you’re validating an email confirmation and you don’t care about the case, it can be skipped with case_sensitive: false

Migrations explains which part is irreversible

In Rails 5 if you’re using a migration method that isn’t reversible (meaning it can’t rollback) you will be warned about the offending method and how to roll your way out of that mess.

Fixed

Passing a relation to cache uses Relation#cache_key

Banking on the cache_key added to relations a while ago, any cache calls in your views correctly use that instead of turning the relation into an array.

bin/rails test -e requires an argument

In Ruby’s OptionParser, if you wrap a parameter in brackets it’s considered optional.

By breaking it out of the brackets, writing bin/rails test -e with an empty argument now raises a more appropriate error.

Array Inquirer finds both symbols and strings

Using any?(:idea) on ["innovative", "idea"].inquiry wouldn’t find anything because the symbol passed to any didn’t match any of the strings in the array.

Now everyone expects the string inquiry — and there’s room for “innovative” “ideas” once again.

Wrapping Up

That’s all for This week in Rails. As always, there are many more changes than we have room to cover here, but feel free to check them out yourself!

Have you been thinking about writing for us, but you’re scared of putting yourself out there? Don’t worry, you can help our editors improve their writing with thoughtful critique and general grammar policing.

You up for that? Tell Godfrey today.

Rails 4.2.4 is out, params.require accepts arrays, Rack 2 is on its way and I'm no longer a teapot!

Hi, everybody! This is Tim and Claudio reporting here from sunny Los Angeles. It’s been a week of intense weather here, and even more intense activity in the Rails community. Let’s take a look at the highlights…

Releases

Rails 4.2.4 and 4.1.13 have been released!

The new versions are backward compatible, so if you are using any 4.2.x version, you can safely upgrade to 4.2.4. And if you are using 4.1.x, bump your Gemfile to 4.1.13.

This week’s Rails contributors

This week 47 awesome people helped to make Rails even better, including 3 for the first time. If you are interested in becoming a contributor, you can have a look at the issues list.

New Stuff

An AsyncAdapter for Active Job

Do you need to create asynchronous jobs without installing additional gems? Set config.active_job.queue_adapter = :async and post your jobs to a concurrent-ruby thread pool.

A new format for params.require

params.require can now take multiple values as an array, allowing for more succinct code such as params.require(:person).require([:first_name, :last_name])

Getting ready for Rack 2

In Rack 2, the env hash will be changed to be actual request and response objects. This commit paves the way for Rails to be compatible when Rack 2 is released.

Improved

Speed improvements for loadable_constants_for_path

Pull requests that improve the performance of Rails are always welcome, especially when they come with benchmarks showing a speed increase of 9x!

Fixed

Goodbye 418 (I’m a teapot)

RFC 7231 changed the list of HTTP status codes (dropping “418 I’m a Teapot” among others). Rails documentation has now been fixed to list the symbols that can be used to represent status codes.

Wrapping Up

One last thing that deserves a mention is that the new Code of Conduct has gone live on the main website. Hurrah!

That’s all for This week in Rails. As always, there are many more changes than we have room to cover here, but feel free to check them out yourself!

Have you been thinking about writing for us, but you’re scared of putting yourself out there? Don’t worry, you can help our editors improve their writing with thoughtful critique and general grammar policing.

You up for that? Tell Godfrey today.

🚂 This week in Rails 🚂: Learn How These 37 Rails Contributors Improved The Entire Framework In Just One Week

Good News Everyone, This Week In Rails has been acquired by BuzzFeed!

Just kidding. This is Godfrey here. It’s been a while since I get to write one of these myself and I’m very happy to be back. Without further ado, let’s dive right into it!

❤️ Code of Conduct

The Rails team is committed to fostering a welcoming community for everyone. With the help of our community, we have added an official Code of Conduct for the project this week.

😱 37 Programmers Contributed To Rails And You Won’t Believe What Happened Next

Well, their pull requests were merged and they are immortalized on the Rails Contributors website. And oh, everyone please send a warm welcome to the 10 first-time contributors this week!

📦 Releases 📦

📢 Sprockets Has Hit Version 3.3.3, What Does That Really Mean For The Rest Of Us?

According to @schneems who is responsible for the release, this is supposed to fix an issue for those of you “who share a cache in different directories between deploys”, which includes Heroku deployments.

💎 New Stuff 💎

💾 MySQL Finally Gets A Native JSON Data Type – But Is It Too Late To Save California?

MySQL has recently added a native JSON data type (perhaps inspired by its more popular cousin, PostgreSQL). Thanks to this patch, you will be ready to take advantage of that feature in Rails 5.

👌 Fixed 👌

🎂 The One Weird Trick That Lets You Write To Files Atomically

Concurrency is hard, but Rails might have finally cracked the nut. You might not know that Active Support offers a way to write to a file atomically with File.atomic_write.

Even if you have heard about it, you probably didn’t realize there is a subtle race condition in its implementation. Anyway, with this patch landing on master, those bugs will soon be behind us and we can all just sit back and enjoy the convenience it provides.

👍 Improved 👍

🚨 Nobody Likes To Do Repeated Work – Here Is A Cache They Won’t Tell You About

It turns out that things do not run twice as fast when you double-cache them. Who would have thought? (I wish we all wrote great commit messages like this by the way!)

✂️ Testing Is Important, But Has Rails Gone Too Far?

Along those same lines, it turns out that testing the same thing twice doesn’t provide much value either.

🙈 Wrapping Up 🙈

That’s all for This week in Rails. As always, there are many more changes than we have room to cover here, but feel free to check them out yourself!

Have you been thinking about writing for us, but you’re scared of putting yourself out there? Don’t worry, you can help our editors improve their writing with thoughtful critique and general grammar policing.

You up for that? Tell Godfrey today.

This week in Rails: Rails 4.2.4 RC1, 4.1.13 RC1 and more!

Hello Everyone! This is Roque bringing the latest from Rails with some help from Kasper.

This Week’s Rails Contributors

We had 36 awesome contributors to the Rails codebase this week. Check out the active issues over on GitHub if you’d like to see your name here.

Rails 4.2.4 RC1 and 4.1.13 RC1 have been released!

There’s new release candidates, please try them and report any regressions you find, so that the Rails team can fix them before the final release.

Thank you to all contributors for these releases!

New Stuff

Active Record relations come in batches

This week Active Record got a new method that works like find_in_batches but yields relations instead of arrays. It also added a cool delegation API that lets you do something like:

People.in_batches.delete_all('age > 21')

Oh, in case you were wondering – this is pretty much how Skynet works.

Improved

i18n reloading picks up new and deleted files

This patch allows new locale YAML files to be loaded without having to restart the Rails server. It also reloads the available locales when files are deleted.

Active Job assertions returns matched job

The matched job returned by these methods can be used for advanced assertions like:

job = assert_enqueued_with(job: SomeJob) do
  some_business_logic
end
assert_equal 5, job.arguments.second

Spun Off

XML serialization have been moved to a gem

As usage for XML serialization declined, it’s become less of a core concern of Rails. In Rails 5, this feature will be moved to the activemodel-serializers-xml gem.

If you’re still using the XML Serialization feature in your app, you will need to add this to your Gemfile when you upgrade.

That’s a wrap

That’s all for This week in Rails. As always, there are many more changes than we have room to cover here, but feel free to check them out yourself!

Have you been thinking about writing for us, but you’re scared of putting yourself out there? Don’t worry, you can help our editors improve their writing with thoughtful critique and general grammar policing.

You up for that? Tell Godfrey today.

This week in Rails: caching madness, Active Job improvements, and even more performance!

What’s up, gang? Todd here with another edition of This Week in Rails. It was a bit of a quiet week in Railsland, but I think we’ve got some quality contributions here. Read on for the deets!

This Week’s Rails Contributors

We had 39 awesome contributors to the Rails codebase this week. Check out the active issues over on GitHub if you’d like to see your name here.

New Stuff

Add #cache_key to ActiveRecord::Relation

This addition bakes a strategy for generating collection cache keys directly into ActiveRecord::Relation. Using #cache_key, it’s now possible to automagically generate a unique key on relations for use with Rails’ fragment cache.

Development Server Caching Toggle

Per a request from DHH, this change adds the ability to enable or disable caching in a development environment. There are two ways to toggle it - on server start with --[no-]dev-caching or with the dev:cache rake task.

Improved

Active Job and Locales

Active Jobs queued with #perform_later previously wouldn’t honor the context’s locale. This patch rectifies that by storing it on the job directly.

Even More Performance Improvements!

By using #start_with? instead of matching on a regex, 765.5 ms have been shaved off of the total aggregate request time per 1000 requests. In conjunction with other performance work recently completed, this knocks a whopping 1.5 seconds off over the course of 1000 requests.

That’s a wrap

That’s all for This week in Rails. As always, there are many more changes than we have room to cover here, but feel free to check them out yourself!

Have you been thinking about writing for us, but you’re scared of putting yourself out there? Don’t worry, you can help our editors improve their writing with thoughtful critique and general grammar policing.

You up for that? Tell Godfrey today.

This week in Rails: wildcard template dependencies and more performance!

Happy Friday Everyone!

This is Greg with the latest news about Rails. We had a quiet week so this issue will be a short one.

This week’s Rails contributors

This week 23 awesome people helped to make Rails even better. If you are interested in becoming a contributor, you can have a look at the issues list.

New Stuff

Wildcard template dependencies

You can define your template dependencies with a wildcard and do more with less code!

Plugin generator for API applications

This pull requests adds an --api option in order to generate plugins that can be added inside API applications.

Improved

Performance improvements

By reducing the number of object allocations, this giant patch helps reduce memory usage and also brings you some significant speed improvement (as a benchmark, codetriage.com ran about 10% faster).

Fixed

Uniqueness validator fix

This commit fixes an issue when using the uniqueness validator against a custom primary key.

That’s a wrap

That’s all for This week in Rails. As always, there are many more changes than we have room to cover here, but feel free to check them out yourself!

Have you been thinking about writing for us, but you’re scared of putting yourself out there? Don’t worry, you can help our editors improve their writing with thoughtful critique and general grammar policing.

You up for that? Tell Godfrey today.

This week in Rails: goodbye Rack::Lock, concurrent-ruby, better AC::Parameters and more

#

Hello Everyone!

This is Vipul from Pune, waiting to enjoy some sweet Sheer khurma, and delicious Biryani with my friends, since Eid is just around the corner.

Hmm, Yum.

This week’s Rails contributors

This week 28 people helped make Rails even more awesome than before. Big thank you to all these amazing people! If you’d like to chip in, there’s always something you could help work on!

New Stuff

Remove Rack::Lock

This is one of the many concurrency-related work that went into Rails this week.

Instead of forcing Rack::Lock when eager_load and cache_classes are off, this change just prevents actual race conditions.

It is achieved by means of a (reentrant) shared-exclusive lock. This allows multiple concurrent requests but ensures any code-loading activity gets performed in isolation.

Improved

Replace ActiveSupport::Concurrency::Latch with Concurrent::CountDownLatch from concurrent-ruby

ActiveSupport::Concurrency::Latch was replaced with Concurrent::CountDownLatch from the concurrent-ruby gem.

This replaces concurrency related code cluttered in AS and offloads it to concurrent-ruby gem, which has many concurrency utilities with runtime-specific optimizations.

Deprecate force association reload by passing true

This is to simplify the association API, as we can call reload on the association proxy or the parent object to get the same result.

So now to reload one would call @user.posts.reload instead of @user.posts(true) for collections and @user.reload.profile instead of @user.profile(true) for singular associations.

See also this mailing list thread for more background information.

Fixed

Test runner now works correctly inside Engines

The bin/rails test has now been extended to work properly instead engines, where previously we needed to do rake test.

ActionController::Parameters no longer inherits from HashWithIndifferentAccess

Inheriting from HashWithIndifferentAccess allowed users to call any enumerable methods on Parameters object, resulting in a risk of losing the permitted? status or even getting back a pure Hash object instead of a Parameters object with proper sanitization.

This change fixes this behavior and makes sure all the methods defined on Parameters will return a Parameters object with the correct permitted? flag.

That’s a wrap

That’s all for This week in Rails. As always, there are many more changes than we have room to cover here, but feel free to check them out yourself!

Have you been thinking about writing for us, but you’re scared of putting yourself out there? Don’t worry, you can help our editors improve their writing with thoughtful critique and general grammar policing.

You up for that? Tell Godfrey today.

This week in Rails: Action Cable, collection caching and more

#

Hi This is Prathamesh bringing together all the latest happenings from the Rails world.

Action Cable alpha is out!

Action Cable is out in wild as promised by DHH in his Railsconf keynote. There is flurry of activity happening with it right now. It’s still in alpha mode and will get production ready with Rails 5.

This week’s Rails contributors

Meet the 21 lovely people who contributed to Rails this week, the community can’t thank you all enough!

New Stuff

Explicit collection caching directive

Now we can explicitly specify collection caching using a special directive # Template Collection. The partials which do not start with <% cache do %> calls will get benefitted by this feature.

Improved

Filter params based on parent keys

Do you have nested params with same child key and different parent keys? Do you want to filter the child keys for only some of the parent keys? Now you can! Params can be filtered based on parent key using a simple config.

Fixed

Fix inconsistent behavior of HWIA with default_proc

Thanks to this fix, behavior of HWIA is now in sync with Ruby’s built-in Hash when a default_proc is set on the instance and it is duped.

That’s a wrap

That’s all for This week in Rails. As always, there are many more changes than we have room to cover here, but feel free to check them out yourself!

Have you been thinking about writing for us, but you’re scared of putting yourself out there? Don’t worry, you can help our editors improve their writing with thoughtful critique and general grammar policing.

You up for that? Tell Godfrey today.

This week in Rails: SQL colors, reversible column defaults and more!

####

Hello? This is your captain Kasper speaking.

We’re just about ready to take to the skies for our weekly cruise through the news. I took a flight course once, and walked away from the crash in flying colors. If my instructor had made it out, I’m sure he would be proud too.

Look at us, we’re already taking off - hey, is that light supposed to be blinking?

This Week’s Rails Contributors

26 daring pilots brimmed the horizon with their commits this week. There were loops and barrel rolls galore - you should have been there! Oh, but you can. See the last item if you feel the need for speed (and contributing).

When SQL Output met Rainbows

In Rails 5 you’ll see your SQL has gotten a fresh coat of paint - several in fact. Now common SQL statements appear in color when sprouting up in your logs. Check the link for the color map.

change\_column\_default Gains Reversible Syntax

Gone are the thrills of remembering past defaults, when you changed it for a column. Both from and to can be passed now: change_column_default(:posts, :state, from: nil, to: "draft")

If all your life’s ROFLMAO’ing have left you with ass left to laugh off, you’ll be ready to migrate and roll back on the floor laughing the remainder of your rear right off over this.

Improved

Windows Users Needs the Latest Development Kit

If you’re a Windows user and witness to the horror of rails new failing with native gems not being able to be installed - rejoice! You need the latest Development Kit version, which our getting started guide will now tell you.

Fixed

where with Association Names are Closer to 4.2

To prevent ambiguity and potential collisions, association names in where are assumed to reference the table name.

default\_render Can Yield When Template is Missing

When a Rails 5 controller action have no corresponding template, Rails renders head :no_content. Before libraries were hooking into the missing template exception being thrown. Now default_render takes a block and the hook is back.

One More Thing™

Feel the need to contribute?

From time to time DHH opens issues on Rails about stuff he’d like implemented. As long as someone hasn’t laid claim to it in the comments (or is assigned) it’s yours to take a stab at.

That’s a wrap

That’s all for This week in Rails. As always, there are many more changes than we have room to cover here, but feel free to check them out yourself!

Have you been thinking about writing for us, but you’re scared of putting yourself out there? Don’t worry, you can help our editors improve their writing with thoughtful critique and general grammar policing.

You up for that? Tell Godfrey today.

This week in Rails: Rails 4.2.3, Rails 4.1.12 and more!

####

Hey there!

This is Claudio, celebrating a historical moment on the road to a better framework for everyone.

This week’s Rails contributors

28 people contributed to the framework by having their commits merged into rails/rails this week. Thanks and keep up the good work!

Rails 4.2.3 and 4.1.12 have been released!

What are you waiting for? Run bundle update rails and get four months of updates in your codebases!

New Stuff

Integrate protected_attributes with strong parameters

Are you still on Rails 3? Do you wish you could use strong parameters? Check out this commit to protected_attributes… it might just make your day.

Sprockets 4.0 is coming

The development of rails/sprockets moves on and… needs your help! If you’d like to contribute to its next version, don’t hesitate to contact any Rails core team member.

Fixed

Raise the proper error on namespaced-association type mismatch

Assigning a wrong value to a namespaced association used to raise NameError, but will now correctly raise ActiveRecord::AssociationTypeMismatch

One More Thing™

Kasper Timm Hansen is a Rails Committer team member

Kasper started contributing one year ago and has not stopped (240 commits and counting)! Thanks for being awesome and for your wonderful blog posts.

That’s a wrap

That’s all for This week in Rails. As always, there are many more changes than we have room to cover here, but feel free to check them out yourself!

Have you been thinking about writing for us, but you’re scared of putting yourself out there? Don’t worry, you can help our editors improve their writing with thoughtful critique and general grammar policing.

You up for that? Tell Godfrey today.

This week in Rails: Security Releases, Enumerable Relations and more!

#

Hey there!

I’m just glad we all made to this Friday. This is Washington again pulling together a few stories for our weekly newsletter on Rails.

This week’s Rails contributors

Keeping our tradition let’s start with the 32 splendid contributors that made their commits to rails/rails this week. Keep in mind a ton other people also helped by creating issues and helping the core team with PR reviews.

Rails security releases 3.2.22, 4.1.11 and 4.2.2

Time to upgrade your applications. Five announcements landed on Rails security mailing list this week. Consider joining that list as well if you haven’t yet.

Improved

Include Enumerable in ActiveRecord::Relation

After a couple years Rails core team seems to have changed its mind and Enumerable is finally included into active record relations. Things change and I believe that’s fine.

Fixed

Autoload ActiveRecord::RecordInvalid

Thanks to the awesome open source community it was noted ActiveRecord::RecordInvalid was not being eager loaded as expected. The fix was backported to all supported branches.

Deprecated

Remove ContentLength middleware from the defaults

As per an old change on Rack spec Rails 5 will no longer ship with ContentLength middlleware by default.

Passing hash as first parameter into ActionController::Head is deprecated

The way to go now is to explicitly pass the status first then pass the options hash as a second parameter.

That’s a wrap

That’s all for This week in Rails. As always, there are many more changes than we have room to cover here, but feel free to check them out yourself!

Have you been thinking about writing for us, but you’re scared of putting yourself out there? Don’t worry, you can help our editors improve their writing with thoughtful critique and general grammar policing.

You up for that? Tell Godfrey today.

This week in Rails: Rails API, fun with minitest and more!

#

Howdy folks!

My name is Todd and I’ll be your guide through the land of Rails this week. Straight from the comfort of my couch with awful lumbar support, I proudly present bad posture and the highlights from This Week in Rails.

This week’s Rails Contributors

42 people made Rails even more awesome this week.

Rails API has landed on master!

After 52 days, lots of great comments, and a ton of incredible work by Santiago and Jorge, Rails API has been merged into master and will be released as part of Rails 5!

New Stuff

Optional scaffold.css

If you’ve ever wanted the ability to avoid generating scaffold.css when performing a scaffold, you’re in luck. Simply use the --no-scaffold-stylesheet switch and you’re good to go!

Improved

Better minitest integration for Rails’ test runner

The new Rails test runner has been modified to take better advantage of minitest’s extension system.

Added a Point object for Postgres point types

Rails 5 will deprecate the current behavior for Postgres point types. Moving forward, the Postgres adapter will return a Point object instead of an Array.

Reversible remove_foreign_key

Migrations using remove_foreign_key can now be automatically reverted with rake db:rollback without manually defining the down operations.

Fixed

Prefix and suffix options for enums

This allows you to add a prefix or suffix to enum’s auto-generated methods. Useful if you have multiple enums with the same values.

Fixed ignore_blank for required select fields

This change will now cause an ArgumentError to be raised in the event ignore_blank is set to false on a required select field.

Fixed abstract class fixtures with belongs_to

Fixes an issue where using belongs_to in abstract classes would result in a crash when loading test fixtures.

That’s a wrap

That’s all for This week in Rails. As always, there are many more changes than we have room to cover here, but feel free to check them out yourself!

Have you been thinking about writing for us, but you’re scared of putting yourself out there? Don’t worry, you can help our editors improve their writing with thoughtful critique and general grammar policing.

You up for that? Tell Godfrey today.

This week in Rails: DateTime vs Time, summer student projects and more!

Hello everyone!

This is Marcel making my ‘initial commit’ with awesome help from Kasper, your friendly ghost editor. Ten minutes from the lovely Jamaican shores, here are the headlines from This Week in Rails.

This week’s Rails Contributors

56 people helped make Rails even more awesome this week.

When should you use DateTime?

Ever wondered what is the difference between DateTime and Time? Checkout this enlightening gist on when you would use each which also landed in the ruby documentation.

Google Summer of Code – Web Console

Follow one of our Google Summer of Code student Hiroyuki on his thoughts, experiments and progress with the web-console browser extension project.

Rails Girls Summer of Code

Meet the 16 official teams that will be participating in the 2015 Rails Girls Summer of Code. We wish them the best of luck.

New Stuff

Custom configurations can be required

Sometimes there’s a configuration your app simply needs to function. Now that important client secret can raise if it hasn’t been set. Just go out with a bang: Rails.application.kitty_litter_supreme.client_secret!

Action Mailer queue name is configurable

Currently all mails sent with deliver_later are put in the mailers queue. This patch keeps that default but allows the queue name to be configured globally via config.action_mailer.deliver_later_queue_name. See also related documentation commit.

Improved

Use inline Gemfile when reporting bugs

No longer do you need to write a physical Gemfile when submitting bug reports, as Bundler 1.10.3 now supports inline gems. Of note, when an inline Gemfile is used, bundle exec is not supported.

Use block variable instead of global

As it turns out using a block variable instead of a “magic” global variable is not only faster but easier to read.

Enumerable#pluck supports multiple attributes

This allows easier integration with Active Record, such that ActiveRecord::Base#pluck will now use Enumerable#pluck if the relation is loaded, without needing to hit the database.

Deprecated

Remove assert_template and assigns()

In order to discourage ties in the controller tests to the internal structure of how your views are organized, assigns and assert_template have both been removed and extracted to the gem rails-controller-testing.

Fixed

Apply Active Record suppression to all saves

Active Record’s suppress is now being applied to non-bang save and update methods. It was also missing from create_* methods provided by singular associations. See gist for more details.

That’s a wrap

That’s all for This week in Rails. As always, there are many more changes than we have room to cover here, but feel free to check them out yourself!

Have you been thinking about writing for us, but you’re scared of putting yourself out there? Don’t worry, you can help our editors improve their writing with thoughtful critique and general grammar policing.

You up for that? Tell Godfrey today.

This week in Rails: Enumerable#pluck, SQLite Collation and lots more

#

Hello everyone!

This is Vipul , happily reporting from a Simmering Summer 😎. Pour yourself a drink 🍹, sit back, relax and enjoy, as we go through these hot off the press changes.

This week’s Rails Contributors

43 people helped make Rails even awesome this week. Checkout the pulse page for more details.

New Stuff

Enumerable#pluck

Enumerable#pluck has just landed on master, providing similar functionality as Active Record’s #pluck.

This allows for something like [{ name: "David" }, { name: "Rafael" }, { name: "Aaron" }].pluck(:name) to get everyone’s names. Pretty handy!

Improved

Collation support in SQLite

Active Record now supports specifying a collation function for SQLite string columns.

Default procs in Attributes API

With the new Attributes API, it is now possible to specify a proc as the default values for an attribute, which allows for runtime-generated default values such as attribute :year, :integer, default: -> { Time.now.year }. See also these related changes.

Preserve MySQL’s sql\_mode with strict: :default

By default, Rails overrides MySQL’s sql_mode setting with sql_mode=STRICT_ALL_TABLES to prevent silent data loss. While this is helpful, it has the unfortunate side-effect of overriding any user customizations.

If you prefer to manage this yourself, you can now specify strict: :default in your connection’s config and Rails will leave your sql_mode alone. (STRICT_ALL_TABLES is still highly recommended though!)

Deprecated

Deprecate render nothing: true

If you are using render nothing: true, you should start replacing it with head :ok, which does the same thing and is more semantic. This option will go away permanently in Rails 5.1.

Deprecate Relation#uniq

The superficial similarity between Relation#uniq and Array#uniq has been a source of confusion, which led to the addition of Relation#distinct which better communicates what is happening under the hood.

The recent discussion on #20198 put the final nail in the coffin for Relation#uniq and its friends, #uniq! and #uniq_value. These methods are deprecated and scheduled for removal in Rails 5.1, so you might want to start using #distinct, #distinct! and #distinct_value soon.

That’s a wrap

That’s all for This week in Rails. As always, there are many more changes than we have room to cover here, but feel free to check them out yourself!

P.S. If you enjoyed this newsletter, why not share it with your friends? :) If you wish to be part of this project please don’t hesitate to contact Godfrey – there’re a lot of ways you could help make this newsletter more awesome!

This week in Rails: try'ing with Delegator, schema cache and a lot more

Hey everyone, this is Prathamesh. Back with latest spells and bindings from magical world of Rails. Keep your wands ready!

This week’s Rails Contributors

39 people got commits into rails/rails this week. And 7 of them made their first patch in this week! Checkout the pulse page for more details.

New Stuff

Support for try with Delegator

Delegator will now respond to try rather than delegating it to the underlying object. Phew! The surprising behavior when using try with normal objects and delegators is gone finally.

Improved

Copy schema cache to new connection pool after fork

Active Record does all the heavy lifting of maintaining and creating connection pools. It just got better. Thanks to this patch, it will copy the schema cache of old connections pools to the new ones if one already exists.

Fixed

Quoted sequence names now work with serial?

Quoted sequence names in PostgreSQL will work properly now with serial? method. Before this patch, the serial? method would return false if the sequence name was quoted. Finally it’s fixed.

One More Thing™

Integer#positive? and Integer#negative? in Ruby core

Last week Integer#positive? and Integer#negative? were added to Rails and this week they became part of Ruby core. Hooray!

That’s a wrap

That’s all for This week in Rails. As always, there are many more changes than we have room to cover here, but feel free to check them out yourself!

P.S. If you enjoyed this newsletter, why not share it with your friends? :) If you wish to be part of this project please don’t hesitate to contact Godfrey – there’re a lot of ways you could help make this newsletter more awesome!

This week in Rails: Connection Pool, Responsive Site, Oh my!

Hey everyone, cough this is cough Kasper.

I’ve been cough sick most of the week and am cough-ing my way through this.

Feel free to insert cough’s through the rest of this, as long as you remember not to snooze on a sneeze or two too.

Alright, cough ‘em up.

This Week’s Rails Contributors

Look at these 31 people and how they’ve hammered away at their keyboards, as if possessed by a different sickness. One of radness that is, my duderinos and duderinas.

Active Record: Connection Pool is More Concurrent

Active Record keeps a pool of database connections. To keep the pool safe from people trying to cannonball queries at once we need to lock it. The pull request slims down what happens when locking, so you can quicker release the lock. Basically more people can go splash, because the diving board is free earlier.

Holy Ruby on Rails on Responsive Website, Batman!

Are you on your phone? Are you on your watch? Are you on the toi… eh, anyway, the Rails website is now responsive.

Just to tide you over until the website redesign will be revealed. That’ll surely be a royal flush.

New Stuff

The Tragoedia and Comoedia of Integers

This week integers gained introspection methods that makes a select a tad easier to read. They are the gangbuster team of negative? and positive?. And hopefully the polarity shockwaves will rock the Ruby world too.

Fixed

Don’t Add to Local Assigns without an Object

If you rendered a partial like <%= render partial: 'spruce_goose' %>, Rails would spruce up local_assigns with the name of the partial. That goose chase ended this week.

One More Thing™

One More Chance to Review Rails API

The option to generate API only Rails apps is almost done. But there’s still a chance to help out by reviewing it. Give it a shot of love!

That’s a wrap

That’s all for This week in Rails. As always, there are more changes than we have room to cover here, but feel free to check them out yourself!

P.S. If you enjoyed this newsletter, why not share it with your friends? :) If you wish to be part of this project please don’t hesitate to contact Godfrey – there’re a lot of ways you could help make this newsletter more awesome!

This week in Rails: Job IDs, inline images preview and more

Hi there!! Washington here again.

Glad we all made to another Friday. A lot of small patches around Rails repository this week. So we had another relatively calm week after the major announcements on RailsConf. The talks list is getting bigger on confreaks by the way. You might want to watch some of those this weekend.

This Week’s Contributors

38 people made it to the Rails repository this week. Check out the pulse page on github too for the full list of recent issues and PRs.

New Stuff

Keeping original job IDs with ActiveJob#provider_job_id

ActiveJob will be able to report the original adapter job ID in Rails 5. The patch started targeting Delayed Job then Sidekiq and Que got their own about a week later. Great team work.

Mailer previews support inline images

This commit adds a preview interceptor to search for inline cid: urls in src attributes and convert them to data urls. P.S. I had to look up the cid protocol myself to get this one.

Deprecated

Removed assigns from functional test templates

Rails is moving towards deprecating the assigns helper on controller tests. The main motivation is that it’s asserting against the internals of the implementation which we shouldn’t care about in a unit test.

See some comments from DHH about that and a couple other test helpers.

Improved

Allow custom response messages on authentication methods

This adds the same functionality already provided in Digest to the HTTPAuth Basic and Token modules.

Apply schema cache dump when creating connections

Quite interesting patch on improving the set up for database connection pools. The schema cache dump will now be applied to every connection as they are created to avoid querying the database for its schema.

That’s a wrap

That’s all for This week in Rails. As always, there are more changes than we have room to cover here, but feel free to check them out yourself!

P.S. If you enjoyed this newsletter, why not share it with your friends? :) If you wish to be part of this project please don’t hesitate to contact Godfrey – there’re a lot of ways you could help make this newsletter more awesome!

This week in Rails: recovering from RailsConf

Happy Friday! It’s Claudio with the latest updates on Rails. Overall, this has been a relaxed week. Many documentation fixes have made their way into master while features uncovered at RailsConf (like the integration of Rails API) are being heavily discussed on GitHub.

This Week’s Contributors

This week 31 people helped Rails out. Six people had their first commit merged into rails/rails. Hooray!

RailsConf 2015 videos

One by one, all the presentations of RailsConf are being uploaded. Lots of great talks to fill your weekend!

GSoC students announced!

We are proud to announce that 8 students will be working on improving Rails as part of the Google Summer of Code 2015. Congratulations and welcome to Rails!

Improved

Better docs for minitest assertions

Rails ships with minitest by default but has different naming conventions for inverse assertion methods. The new guides clarify this difference. And give us a great excuse to link to Ruby on Rails on Minitest.

Toward a better “Caching with Rails” guide

Everyone can help make Rails better by improving its guides. “Caching with Rails” is an awesome place to start. If you think you can improve it, don’t hesitate to submit a pull request!

Remove use of mocha in the named-base tests

Some tests in the Rails codebase use the mocha library and can be faster by using minitest/mock instead. This commit fixes one of those tests; you are all invited to do the same for the remaining ones.

Fixed

Rake routes not showing right format when nested

The rake routes command was not properly showing nested routes with a scope constraint for the format override by a resource… but that just got fixed!

That’s a wrap

That’s all for This week in Rails. As always, there are more changes than we have room to cover here, but feel free to check them out yourself!

P.S. If you enjoyed this newsletter, why not share it with your friends? :) If you wish to be part of this project please don’t hesitate to contact Godfrey – there’re a lot of ways you could help make this newsletter more awesome!

This week in Rails: RailsConf 2015 Edition

ZOMG! Hello everyone, it is Godfrey here (it’s been a while!), delivering the latest news from Rails to your inbox. This happens to be RailsConf week, so we have lots to cover; lets get to it!

Note: The links to the RailsConf videos are the unedited live-stream versions, and they might be removed later. Also, only talks from the keynote room are available at the moment, but don’t worry – the full set of talks will eventually be made available to everyone. Follow @railsconf to stay in the loop!

Rails Conf 2015

Day 1: DHH keynote, Sara Chipps keynote

David Heinemeier Hansson kicked off the conference by announcing a few new features in Rails 5: Rails API, turbolinks 3, a native mobile wrapper and web sockets support (a.k.a. Action Cable).

The amazing Sara Chipps wrapped up the day by sharing her experience teaching kids to code.

Check the schedule for a full list of talks from Room 202. Shameless plug: yours truly gave a talk following the DHH keynote ;)

Day 2: Aaron Patterson keynote, lightning talks

Aaron Patterson started the second day with a punishing amount of word play jokes. In between trolling other keynote speakers and rebooting his computer, he also dropped an incredible amount of performance knowledge.

Don’t forget to catch the lightning talks towards the end of the stream!

Day 3: Ruby heroes, core team panel, Kent Beck closing keynote

The Ruby heroes awards were given on the third day, followed by a panel discussion featuring some members from the Rails core team.

Kent Beck, aka the creator of XP (not to be confused with the other XP) wrapped up the conference with a focus on the human elements of programming.

This week’s Rails contributors

Just because it is Rails Conf, it doesn’t mean contributions to the Rails codebase will see any slow down. In fact, 37 contributors made their mark on Rails this week, with 11 first-time contributors!

Rails API

As mentioned in David’s keynote, Rails API will be part of Rails 5. Follow the pull request to track the progress and chime in on the discussion. (Please avoid leaving +1 comments!)

New Stuff

Generic bug report template

Joining the existing bug report templates, this new template will be handy for reproducing small bugs with a minimal setup. Check the contributing guide for details.

[attr_name]_previously_changed?

With this patch, you can easily check if a single attribute has previously changed and react to those changes appropriately.

That’s a wrap

It’s been quite a week! We didn’t have room to cover everything that happened in Rails, so head over and take a look for yourself.

Thank you for your continued support for the newsletter. (I am very glad to have met a few of you at RailsConf!) As always, feel free to share this with your friends. If you have any comments or would like to help, drop me a line!

This week in Rails: Ruby 2.2.2, RailsConf and more!

Hey reader, Kasper here.

I’m sole jammin’ and grand slammin’ words into your inbox.

But before the Rails juice, a quick story spruce: At my company we have a coworker we look up to, because she’s doing a cross country trek.

She’s our heroine and she just crossed the border.

Oh right, you were looking for Rails news.

This Week’s Contributors

This week 42 people helped Rails out. Rails 5 comes closer everyday and it’s only possible because of all your help. Keep it up and it’ll be the best version of Rails yet.

prepend Primed to Dethrone alias_method_chain

Remember when we said alias_method_chain had been deprecated? Well, if the method being overriden called super, you’d be stuck in an infinite recursion - like that friend who didn’t graduate kindergarten. This week prepend became the successor Rails needs. And how is that possible?

Rails 5 Requires Ruby 2.2.2

Well, I’m glad you kept reading, because Ruby 2.2.2 has a fix for prepend. The new version is mainly a security release - with some bug fixes squeezed in there - so no procrastinating the upgrade, okay? You want to be ready to hit the lab next week too.

New Stuff

Controllers With Default Form Builders

There’s a new default_form_builder method you can override in controllers. Then form_for and friends will use the passed builder class to architect the view.

A new Action Pack XML Parser Release

Hey, there’s a new version of this thing out.                                                  

Improved

Railties Uses Bundler’s exe Convention

You’ve probably been prepending bin when running rake or rails like a good samaritan. Those are binstubs in action. But bin is for executables in general and not just those stubs. Not anymore, as Bundler reserves bin for binstubs and exe for executables. This week Railties executed that convention.

One More Thing™

Meet Us at RailsConf

A few of us are going to the big peach next week. So after you’ve seen DHH reveal the really big stuff coming in Rails 5, you can mingle with us at RailsConf. Both Godfrey and Claudio will be speaking. …and I guess I’m there too.

That’s a wrap

Another week in Rails went by - and so swiftly. There’s more changes in this tailored link.

Lastly, either pluck in a few of your friends’ emails here or ask Godfrey how you can get to write these things too.

This week in Rails: batch touching, default controller response and more!

Hey there, this is Washington. It’s finally Friday again!!!

A lot of bug fixing and a couple great improvements going on the Rails environment this week. Read on for more details.

This week’s Rails contributors

31 contributors have helped improve Rails this week. Consider taking some time next week to make a contribution to an open-source project :) (I keep telling that to myself every day)

Improved

Batch touch parent records

YAY! I bet many projects have been looking forward to this improvement. After a couple discussions and experiments touching is finally limited to the fewest possible number of queries.

Controller actions default to head :no_content if no template exists

After all these years DHH is still pushing for better defaults on Rails. Next major version will assume everything went fine if a controller action has no template. I can’t see why not.

Fixed

Non-ascii characters in URLs on Windows

We are a few months into 2015, but these encoding-related problems are still haunting us! With this fix, Windows apps will stop blowing up on strange URLs. Yet another example of how awesome the Ruby and Rails community can be.

Error when defining callbacks named run

An apparently nice performance improvement has caused a regression on the callback system. Plus according to new benchmarks it seems the original performance improvement is no longer relevant.

force_ssl without session_store

config.force_ssl = true now works properly even when you have disabled the session store.

Uniqueness validations and out-of-range integers on PostgreSQL

Another patch to make Active Record API rock solid.

One More Thing™

Redcarpet 3.2.2 has an XSS vulnerability

I haven’t seen much noise about this vulnerability on the interwebs but just in case. If you have this markdown parser on any of your projects you should probably bump it whenever you have a chance.

Wrapping up

That’s all for This week in Rails. As always, there are more changes than we have room to cover here, but feel free to check them out yourself!

P.S. If you enjoyed this newsletter, why not share it with your friends? :) If you wish to be part of this project please don’t hesitate to contact Godfrey – there’re a lot of ways you could help make this newsletter more awesome!

This week in Rails

Happy Good Friday Everyone!

Here comes the gist of last week’s interesting commits from Rails. Stay tuned!

This week’s Rails contributors

We had 30 amazing contributors this week, big thanks to all them!

New Stuff

Explicit base class for Active Job jobs

It is recommended to not change settings on ActiveJob::Base directly so from now on every generated Job will inherit from ApplicationJob and you can tweak that for your needs.

Rails uses Sprockets 3 now!

Sprockets 3 will be released soon and the Rails team decided to give the release candidate a try.

Deprecated

Deprecate the :tokenizer option in validates_length_of

This option only served an extremely specific use case hence became deprecated. If you rely on this functionality, you can implement it with a plain Ruby method.

Improved

Only coerce time in comparison if necessary

In the development environment ActiveSupport::FileUpdateChecker#max_mtim triggers many time comparison and there were many unnecessary to_time calls. With this patch Rails saves around 100ms per request!

Reduce memory usage when loading types in Postgres

The PG::Result object were never cleared when the application queries the types. By clearing that object Rails use less memory.

Fixed

Return super in ActionController::Parameters.const_missing

With this pull request ActionController::Parameters.const_missing’s super is always returned whereas before it was only called and its return value was mistakenly discarded.

Wrapping up

That’s all for This week in Rails. As always, there are more changes than we have room to cover here, but feel free to check them out yourself!

P.S. If you enjoyed this newsletter, why not share it with your friends? :) If you wish to be part of this project please don’t hesitate to contact Godfrey – there’re a lot of ways you could help make this newsletter more awesome!

This week in Rails: Goodbye alias_method_chain, PostgreSQL typecasting and more

Hey all!

This is Prathamesh with this week’s recap from Rails. Lets see which issues got fixed, which features got added. Ready, steady, go!

This week’s Rails contributors

This week 40 people contributed to Rails, 7 out of them are new. Do you also want to help? Check out the issue tracker and start making Rails better.

By the way, Xavier and Kasper added the permalink feature to the link of weekly contributors. So each weekly contributors link is forever to stay!

New Stuff

Warning if the query fetches more than fixed number of records

Faced problem with queries fetching thousands of records and slowing everything? Now you will get a nice warning if the query fetches more number of records than configured value by using active_record.warn_on_records_fetched_greater_than config option.

Deprecated

Deprecate alias_method_chain in favor of Module#prepend

Do you remember the old friend alias_method_chain? It had a good run. But now it will be deprecated in Rails 5 in favor of Module#prepend which was introduced in Ruby 2.0.

Improved

Moving type casting for PostgreSQL out of Active Record

We just got two steps closer to moving type casting of various data types for PostgreSQL from Active Record to PostgreSQL adapter.

Friendlier access to request variants

With this patch, you can now check the current request’s variant using request.variant.phone?, request.variant.tablet? and so on.

Fixed

Pass name of the wrapped job class to Sidekiq for logging

If you were missing your job class in the Sidekiq logs and instead seeing some weird ActiveJob::JobWrapper, don’t worry. Now you will get your job class back in the logs because ActiveJob will pass the wrapped class name back to Sidekiq.

Use actual table name while joining tables with has_many :through

Previously, while joining tables having has_many :through association, Active Record was not using the actual table name. It was generating wrong SQL and resulting into ActiveRecord::InvalidStatement error when used with calculation methods like #count. No need to worry, its fixed now!

Generate fixture file with singular name for singular tables

Previously if the table name was made singular using ActiveRecord::Base.pluaralize_table_names = false, name of the fixture file getting generated was still pluralized. No longer true! Get singular fixture file for singular table name now onwards.

Summer Opportunity

Rails Girls Summer of Code

Checkout Rails Girls summer of code. You can submit your open source project to be included. Also you can help fund the campaign.

Wrapping up

That’s all for This week in Rails. As always, there are more changes than we have room to cover here, but feel free to check them out yourself!

P.S. If you enjoyed this newsletter, why not share it with your friends? :) If you wish to be part of this project please don’t hesitate to contact Godfrey – there’re a lot of ways you could help make this newsletter more awesome!

This week in Rails: 4.2.1, 4.1.10, new test runner and more!

Hello Everyone!

This is Vipul from Pune, where it’s the Gudi-Padwa – or the Marathi New Year! Surrounded by garlands of sweets, lets head on to see, whats exciting this week.

P.S. Happy New Year!
P.P.S. Isn’t it a New Year, everyday somewhere around the World?

This week’s Rails contributors

36 people contributed to make Rails awesome this week. If you haven’t already, go ahead and watch Rails on GitHub to follow the discussions and find your first opprtunity to help out!

Rails 4.2.1 and 4.1.10 have been released!

After four release candidates, Rails 4.2.1 and 4.1.10 have finally been released! Thanks to all the contributors, for tons of fixes. Check out the full changes for 4.2.1 and 4.1.10 respectively.

New Stuff

bin/rails test runner

A new test runner – bin/rails test – has landed on master. This is the successor to the rake-based test runner, and includes a few rspec-inspired features that are not part of minitest, like running by line number, rerun snippets, or logs displayed with unicorns filled with rainbow colors.

Added rake initializers

Need to see all those initializers scattered in you application? Worry no more. Just run rake initializers! Did I mention they are sorted?

Improved

Use fullpath from Rack request

In Rack, request#fullpath returns the full path including the query string. This change uses fullpath from rack to avoid doing the same thing again in Rails. As a result, we also reduced some object allocations!

Fixed

Materialize subqueries by adding DISTINCT to suport MySQL 5.7.6+

In MySQL 5.7.6+, the default value for optimizer_switch has changed to derived_merge=on, which causes some issue with the subqueries generated by Rails. This change fixes that by adding a DISTINCT to the subqueries.

Don’t cast nil to string in postgres enums

Previously, nil values in PostgreSQL enums were casted to an empty string, which causes an error somewhere down the chain. But worry no more – this has now been fixed!

Summer Opportunities

Google Summer of Code 2015

Are you a student, or know someone who would love to contribute to Rails? Our GSoC students application is now open! Check out our ideas page and join us on the mailing list for discussion.

Rails Girls Summer of Code

Rails Girls Summer of Code is also accepting application! You can also consider submiting your open-source project to be included.

Wrapping up

That’s all for This week in Rails. As always, there are more changes than we have room to cover here, but feel free to check them out yourself!

P.S. If you enjoyed this newsletter, why not share it with your friends? :) If you wish to be part of this project please don’t hesitate to contact Godfrey – there’re a lot of ways you could help make this newsletter more awesome!

This week in Rails: RC releases, summer opportunities, turbo partials and more!

Hi all! o/

Here is Washington bringing you this week’s news from our favorite framework. I hope you have made it to Friday the 13th without any major hiccups (I can’t say the same about my internet provider). Either way, it’s time to grab a drink, wind down and read on!

4.2.1.rc4 and 4.1.10.rc4 have been released

Give them a try on your projects to help make the next release as rock solid as possible. Many regressions have already been fixed and the final release should be out on March 17.

This week’s Rails contributors

Couple more developers made their first commit into Rails this week. Take a moment to review the open issues, perhaps you will find something related to your day job, manage to fix it and have your first patch in Rails!

Summer Opportunities

Google Summer of Code 2015

It’s that time of the year again! As reported last week, we have been selected to participate in this year’s Google Summer of Code program. This week, a few more exciting ideas have landed on our project page!

Applications will open next week, so please help spread the word!

Rails Girls Summer of Code

Speaking of summer, Rails Girls Summer of Code have just opened their applications today. If your company can afford it, consider becoming a sponsor!

New Stuff

Mostly inspired by shopify/turbograft turbolinks now also supports partial replacement. Checkout the PR with docs as well for usage details.

Improved

All Rails tests run in random order

As of this week Rails is giving another try on running tests in random order!!! You should probably try the same on all your projects for more reliable test results.

Fixed

Rails 5 will need Ruby 2.2.1 or higher

Apparently Ruby 2.2.0 kwargs were still not that stable. A related issue caused a segfault error on ActionPack tests. So Rails 5 will require at least Ruby 2.2.1.

Fix rollback of frozen records

In case your project upgrade to Rails 4.2.0 raised any Can’t modify frozen hash errors, checkout the latest release candidate. Chances are it will be fixed in Rails 4.2.1.

Wrapping up

That’s all for This week in Rails. As always, there are more changes than we have room to cover here, but feel free to check them out yourself!

P.S. If you enjoyed this newsletter, why not share it with your friends? :) If you wish to be part of this project please don’t hesitate to contact Godfrey – there’re a lot of ways you could help make this newsletter more awesome!

This week in Rails: 50,000 commits, GSoC opportunity and more!

Ahoy there, rapscallion.

We’re just about to depart for our weekly voyage on the sea of Rails news - beware the great snark!

Captain Kasper abides seas and appeases gods in hopes we make it ashore.

Come aboard and let’s cast away.

Rails crossed 50,000 commits

Our backs are all red from the pats given when news broke of Rails having more than 50,000 commits.
Adding to that chalupa 42 chummy contributors crossed the web and helped out.

10+ Years of Rails with DHH

Listen in as David takes a trip down memory lane. Hear why he made Rails and get some stories on the early days of Rails contributing. He also has some thoughts about money and open source. It might not be such a good thing to get paid to work on open source, after all.

Rails & Google Summer of Code 2015

Speaking of being paid for open source, Rails will be part of this year’s GSoC. I was a student two years ago and wouldn’t be here without it.

I highly recommend doing your research. Submit an honest proposal and you just might make it.

Seagulls of the Sea

Damn Winged Creatures in my Newsletter

There we were. Having a nice day on the deck and a seagull wants to join in on the fun of staring at peaceful waters. Not on my watch.

waves broom

Return to the sea, beast!

New Stuff

Added restart rake task

Rails 5 brings a restart Dr. Frankenstein would be envious of. The new rake restart command will knock your app out cold and zap it back to life.

Enumerable#without

We also got a new Enumerable method to quickly rid of us stuff harmful to humans: [:whooping_cough, :vaccine, :measles].without(:vaccine).

Finally, we can sleep easy.

Wrapping up

That’s all for This week in Rails. As always, there are more changes than we have room to cover here, but feel free to check them out yourself!

P.S. If you enjoyed this newsletter, why not share it with your friends? :) If you wish to be part of this project please don’t hesitate to contact Godfrey – there’re a lot of ways you could help make this newsletter more awesome!

This week in Rails

Another week went by and here we are again, this is Greg with the latest news from the Rails community.

This Week’s Contributors

36 amazing people helped to make Rails even better this week! Thanks everyone!

Interview with Carlos Antonio and Rafael França

Interview with Rails Core team members about early days of their Rails contribution, Rails team, Brazil Rails community, their day to day tools of choice and workflow, and how everyone can help out with Rails.

New Stuff

Default belongs_to validation

belongs_to relations will now trigger a validation error by default if the association is not present. If you wish, you can turn this off with the optional: true option per association.

Move the validate! method to ActiveModel::Validations

validate! was part of Active Record, but with this commit you can use it on any Active Model object!

Allow limit option for MySQL bigint primary keys

From now on, you can set a limit for your bigint type primary keys in MySQL.

Improved

Faster template partial caching

Collections automatically use a read_multi for partials starting with a cache call from now on, which makes them faster.

Fixed

Fixed ActiveModel.model_name.to_json

Previously, calling User.model_name.to_json would result in an infinite recursion, because .model_name inherited .as_json from Object. This commit delegates as_json to the correct handler to fix that.

Fixed mysql’s schema.rb dumper

MySQL doesn’t have a boolean datatype, it uses a tinyint with a limit option, so if we dumped the schema from MySQL we couldn’t load it to Postgres since limit is invalid for Postgres booleans. This patch fixes that by not adding the limit to schema.rb.

Deprecated

skip_action_callback is deprecated

In future skip_before_action, skip_after_action and skip_around_action will raise an ArgumentError if the callback doesn’t exist, so using skip_action_callback, which calls all three methods will probably fail, therefore it became deprecated.

One More Thing™

Richard Schneeman is a Rails Committer!

Please welcome our newest Rails Committer @schneems!

Wrapping up

That’s all for This week in Rails. As always, there are more changes than we have room to cover here, but feel free to check them out yourself!

P.S. If you enjoyed this newsletter, why not share it with your friends? :) If you wish to be part of this project please don’t hesitate to contact Godfrey – there’re a lot of ways you could help make this newsletter more awesome!

This week in Rails: http_cache_forever, AR::Base.suppress and more!

My Valentine’s Day letter to Ruby on Rails:

“Dear Rails, remember the first time we met?
You were just 1.2, and I was in an unhealthy relationship with Perl and PHP.

I saw you in the library and I immediately fell in love.
For seven years, you made my code more readable and my skills stronger.

You are the most beautiful framework and always will be.
I cannot wait to see you turn 5.0.” – Claudio

This Week’s Contributors

Apparently I’m not the only one in love with Ruby on Rails. 36 programmers contributed to Rails this week, 10 of them for the first time. Keep loving!

New Stuff

Add http_cache_forever to ActionController

The new method is perfect to cache results that are meant to never expire, such as static pages.

Add ActiveRecord::Type.register

You can now reference with a symbol any database type that is specific to your adapter, such as:
ActiveRecord::Type.register(:money, MyMoneyType)

Add ActiveRecord::Base.suppress

Wrapping a block with suppress will prevent any save operation from hitting the database. Check the PR for a real-world example.

Improved

Add :time option to ActiveRecord::Base.touch

You can now touch an ActiveRecord instance with a different time than the current time.

Removed

Removed RecordTagHelper

The helpers div_for and content_tag_for will be gone in Rails 5. Grab the record_tag_helper gem if you still need them!

Removed ActiveModel::Errors getters/setters

If you ever used person.errors.get(:name) or person.errors[:name] to read an error message, you should now switch to person.errors.messages[:name]. add_on_empty and add_on_blank are gone too.

Update: you should be using person.errors[:name] after all! Use person.errors.add(:name, ...) to append.

Wrapping up

That’s all for This week in Rails. As always, there are more changes than we have room to cover here, but feel free to check them out yourself!

P.S. If you enjoyed this newsletter, why not share it with your friends? :) If you wish to be part of this project please don’t hesitate to contact Godfrey – there’re a lot of ways you could help make this newsletter more awesome!

This week in Rails: Speedy Integration Tests, Enum Queries and more!

Dearest darling, reindeer-eyed reader

Hither summoned is Kasper, Duke of Friendly Ghosts, to bring forth thy worthy commits and Pull Requests of Rails as subscribed.

Thusly commences our journey on this Friday the 13th - Ok, I’m sick of writing like that.

This Week’s Contributors

A round of applause goes to this weeks contributors from all of us at this virtual news desk. We editors did a full on spit take when realizing a whopping 28 people contributed. Nothing seals that memory quite like the scalding coffee on our thighs.

Integration Tests Only 12% Slower than Controller Tests

You may have thought Speed was just a movie. But we’re feeling it this week as our world got rocked with a refactoring bringing integrations’ speed closer to functionals. Stay at the edge of your seats for the sequel.

Improved

Make enums queryable by label

After an amazing refactoring job on Active Record internals that took many months, this change was easy. Enums can now be queried by their labels. Post.where(status: Post.statuses[:draft]) is out in favor of Post.where(status: :draft).

fresh_when and stale? accepts a collection

They say that stale? is everyone’s best friend. It will be by you until you get to fresh_when. Even if you need help when a collection seems impassable. Look around, you dingus, your best friends are adaptable.

There’s usage examples on the Pull Request.

find_in_batches got an end_at option

Sometimes you gotta know when the fun oughta stop. Sadly find_in_batches and find_each would keep going like the party animals they are. Or were, as both matured this week with a new end_at option. But they’re still keeping it plenty rad in their parents basement if anybody asks.

One More Thing™

Kasper Timm Hansen is an issues team member

Kasper first impressed us when he shipped his 2013 Rails GSoC project in 2014. In his spare time he writes a newsletter called This Week in Rails. In fact he wrote this very issue. Aw shucks, I thought there was something familiar about me and I!

Wrapping up

This was a weird one, right? Hopefully of the glorious kind.

That’s all for This week in Rails. As always, there are more changes than we have room to cover here, but feel free to check them out yourself!

P.S. If you enjoyed this newsletter, why not share it with your friends? :) If you wish to be part of this project please don’t hesitate to contact Godfrey – there’re a lot of ways you could help make this newsletter more awesome!

This week in Rails: locate_many, emoji partials and more!

Hey there!

Newsletter team is back to your inbox delivering all latest good commits and pull requests from Rails. Hopefully you have your favorite drink right there with you to make this quick reading ever better.

This week’s Rails contributors

Over 25 people contributed to Rails this week alone. Perhaps by our next newsletter your name could be on that list too!

Improved

Efficient lookup for many models in Global ID

Latest version of Global ID 0.3.2 brings better look up for models. You can pass an array of ids to locate_many to fetch records only once per model. Check out the juicy comments of Core Team members figuring out their own API.

Partial names don’t have to be valid Ruby identifiers

Rails master can render partial names like _the-friday-party.html.erb just fine now as well. If you are feeling extra adventurous, you might even try naming your partials with emojis!

perform_enqueued_jobs can filter jobs by type

By passing a only option you are able to test only those particular jobs while any other inside the block won’t be performed. Checkout the changelog entry introduced for a crystal clear example usage.

Fixed

Child record validation respects validate: false on parents

Took a few years but this is fixed! Persisting child records will respect the current validation state of the parent record. Also good to see how the team is worrying about performance penalties for fixes in ActiveRecord core logic.

Removed

Dropping xhr helper to simplify AC::TestCase

You will need to update your test suites in case they use either xhr or xml_http_request test helpers. Instead switch to the regular get and pass the keyword argument xhr: true

Farewell Rails built in documentation tasks

Now comes a goodbye to a few friends most of us never knew we had: the documentation rake tasks. The three siblings doc:app, doc:rails and little doc:guides joins local documentation in a better place - online. Our thoughts are with the remaining rake tasks. Rest In Protocols.

One More Thing™

Eileen M. Uchitelle is a Rails Committer

Eileen has been doing awesome work on Active Record related to performance refactoring and bug fixes besides mentoring some students in the Facebook Open Academy program.

Wrapping up

That’s all for This week in Rails. As always, there are more changes than we have room to cover here, but feel free to check them out yourself!

P.S. If you enjoyed this newsletter, why not share it with your friends? :) If you wish to be part of this project please don’t hesitate to contact Godfrey – there’re a lot of ways you could help make this newsletter more awesome!

This week in Rails: Relation#or, file fixtures, kwargs and more!

It is that time of the week again!

This is Greg, bringing you this week’s interesting commits and pull requests from Rails.

This week’s Rails contributors

Let’s start with a big thank you for all the people who helped this week to make Rails better!

New Stuff

Added #or to ActiveRecord::Relation

A long waited feature is added to Active Record and from now on you can combine two Active Record relations with the or operator.

ActiveSupport::Testing::FileFixtures

With this addition to ActiveSupport::Testing there is no need to write custom helpers for testing features requiring a sample file (i.e. file uploads).

Use kwargs in the test’s HTTP methods

Support for keyword arguments is added to the HTTP methods of the controller tests. An example of the new syntax:

post :create, params: { y: x }, format: :json

Improved

Improved performance of integration tests

delegate turned out to be a bottleneck at the URL generation in the integration tests. With this patch the integration tests of the applications should have a speedup.

Allow hyphenated names for plugins

From now on you can generate a Rails plugin with a hyphenated name (i.e. namespaced engines).

Deprecated

*_via_redirect integration test methods are deprecated

The *_via_redirect methods are deprecated but do not fear, you can use follow_redirect! in your test suite for the same behaviour.

Fixed

Fixed HTTP basic authentication nil issue

When request.authorization returned nil, Rails raised a NoMethodError, but this is fixed now.

AR::Relation#group accepts SQL reserved keywords

This patch allows you to group by SQL reserved keywords with the group method of Active Record.

One More Thing™

Arthur Nogueira Neves is a Rails Committer

Please welcome our newest Rails Committer!

Wrapping up

That’s all for This week in Rails. As always, there are more changes than we have room to cover here, but feel free to check them out yourself!

P.S. If you enjoyed this newsletter, why not share it with your friends? :) If you wish to be part of this project please don’t hesitate to contact Godfrey – there’re a lot of ways you could help make this newsletter more awesome!

This week in Rails: model error details, drop table if exists and more!

It’s Friday! Gotta get down on This Week in Rails!

This is Claudio, rushing to get you the weekly updates on interesting commits and pull requests from Rails.

This week’s Rails contributors

25 contributors helped Rails become a better framework. Keep the patches coming, and Rails 5 will be ready before you know it.

New Stuff

ActiveModel::Errors#details

Given a user without an email, user.errors.details will return {email: [{error: :blank}]}. In some cases, this is more useful than the message {email: ["can't be blank"]} provided by user.errors.messages.
There’s a good usage example in this blog post.

:if_exists option for drop_table

Writing drop_table(:users, if_exists: true) in a migration ensures that the migration will run without exceptions, whether or not the “users” table exists.

ActionController::Renderer

The ActionController::Base#render method can now output a template anywhere, even outside of a controller!

ActiveRecord::Base#accessed_fields

Calling @users = User.all to list all users works, but you can get better performance by indicating the exact fields you intend to access, for instance with @users = User.select(:name, :email).

The new @users.accessed_fields method will give you the list of fields accessed from the model, so you can easily optimize your queries using .select rather than .all.

Improved

Speed up ActionController::Renderer

Everyone loves a pull request that speeds up Rails, especially if the performance gain is documented and verifiable.
When in doubt, always use benchmark/ips to provide benchmark results for comparison.

Wrapping up

That’s all for This week in Rails. As always, there are more changes than we have room to cover here, but feel free to check them out yourself!

P.S. If you enjoyed this newsletter, why not share it with your friends? :) If you wish to be part of this project please don’t hesitate to contact Godfrey – there’re a lot of ways you could help make this newsletter more awesome!

This week in Rails: tokens migrations, method_source and more

Live from our servers, it’s This Week in Rails!

As always we’re your inside scoop of interesting commits, pull requests and more from Rails.

This is Kasper, and I’m ready to serve you this scoop. I tapped keys on the board in front of me to make words appear. It’s quite the tapestry.

Let’s get to it!

This week’s Rails contributors

33 contributors made this week happen. Pull Requests were merged, new friendships were made… I think I even heard someone say they saw a cat online. That’s a rare sight, and part of what made this week special. Thanks everyone!

Tokens in migrations and model generators

As a follow up to last week’s has_secure_token, both the migration and model generators can create token attributes.
rails g migration add_auth_token_to_users auth_token:token. rails g model user auth_token:token.
The model generator automatically adds has_secure_token :auth_token to your new model file.

New Stuff

method_source added to the default Gemfile

On Rails 5 when you generate a new app, you’ll find ‘method_source’ in your Gemfile. This gem extends the Method class with source and comment methods to aid your debugging. There’s a good usage example in this comment.

Fixed

Allow ‘1’ or true for acceptance validation

Previously validates_acceptance_of would only accept ‘1’ as a valid attribute value. Now you can assign true to an attribute and the validation will pass.

Time columns will be aware of application time zone

In Rails 5.1 your time columns will adhere to the time zone of your Rails application. To make the upgrade path smoother, the config.active_record.time_zone_aware_types option has been added. See the deprecation warning here for help.

One More Thing™

Validation callbacks tested with contexts

A feature you might not have heard about is validation contexts, which allow you to specify a context a callback should only be run for. Like this: before_validation callback, on: :create. The link shows a few tests being for this on before/after_validation. Here is a more advanced example.

Wrapping up

That’s all for This week in Rails. As always, there are more changes than we have room to cover here, but feel free to check them out yourself!

P.S. If you enjoyed this newsletter, why not share it with your friends? :) If you wish to be part of this project please don’t hesitate to contact Godfrey – there’re a lot of ways you could help make this newsletter more awesome!

This week in Rails: a new beginning

Happy New Year, everyone!

It was only less than a year ago when I sent the first issue of This week in Rails to a total of 14 recipients, discussing some of the latest and greatest additions to the Rails codebase.

43 weeks later, this little hobby project has evolved into a true community effort –- we have assembled an amazing team of editors and other volunteers (join us!), keeping 2000 subscribers in the loop and highlighting some key contributions to our beloved web framework every week.

I am incredibly excited to announce that starting this week, we will be cross- posting the content from the newsletter to the Riding Rails blog. With this, we hope to reach even more members of our wonderful community, increase transparency, involve more of you in the decision-making processes and maybe even inspire some future contributors!

I would like to thank my team at Brewhouse and Goodbits for supporting the project and getting it off the ground, as well as all the volunteers who helped along the way. Of course, huge thank you to all of the Rails contributors who did all the hard work! <3 <3 <3

Without further ado, here is the first 2015 issue of This week in Rails!


Welcome to This week in Rails, your weekly inside scoop of interesting commits, pull requests and more from Rails.

Hi there this is Washington again!

Hope you all had the most gorgeous holidays ever doing things you love the most. The newsletter team is back to work and you should receive your Rails weekly news as usual. Here are some of the latest and greatest improvements, fixes and releases during the break.

Ruby 2.2.0 Released

YAY! December 25th saw another important Ruby release. See the blog post for all the goodies in this new version and keep in mind Rails 5 will target Ruby 2.2+ exclusively. As of this week, Rails’ master branch will only work on Ruby 2.2 or above.

Rails 4.0.13 and 4.1.9 have been released!

4.0.13 is last planned release for the 4.0 release series, so you should migrate off it as soon as possible. From here on, the 4.1 (you can thank Rafael) and 4.2 release series will continue to receive regular bug fixes. Consult the maintenance policy for details.

This week’s Rails Contributors

Apparently holidays is no excuse for going to the beach all day long and having drinks away from computers. Rails community kept working hard during the break to keep improving the framework we appreciate so much. Thank you all!

New Stuff

Halting callback chains by throwing :abort

As of Rails 5 callback chains won’t be halted by returning false. Instead you should explicitly throw :abort. This will help keep things consistent among all frameworks included in Rails and avoid accidental halting caused by unexpected false return values.

New date helper

Working with days and weeks just got a bit easier. Keep in mind these new helpers on_weekend?, next_weekday, prev_weekday, next_day, prev_day. Perhaps you had even implemented them before yourself! Good thing Rails will have them out of the box now :)

has_secure_token in Active Record

Rails will ship with a new Active Record macro for generating base 58 tokens out of the box. There’s probably a large amount of applications already using this feature. As of the next major release you won’t need to add another dependency or implement it yourself.

Fixed

More conventional filenames for mailers

Mailer generators now appends the _mailer suffix in the filename just like controller and jobs generators.

Rails 5.0 deprecations clean up

This week Rails got some more love with this major clean up (339 additions and 1,433 deletions) on its master branch. There’s still some deprecations left though as the team figures how to best address them.

One More Thing™

Automatic type casting deprecated in Arel

Watch out library authors! Sean Griffin put a lot of effort into improving Arel extensibility. Please get in touch with him if you need APIs to help your use case. (See also these follow-up commits.)

Wrapping up

That’s all for This week in Rails. As always, there are more changes than we have room to cover here, but feel free to check them out yourself!

P.S. If you enjoyed this newsletter, why not share it with your friends? :) If you wish to be part of this project please don’t hesitate to contact Godfrey – there’re a lot of ways you could help make this newsletter more awesome!