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!

[ANN] Rails 4.2.5.rc1 and 4.1.14.rc1 have been released!

Hi everyone,

I am happy to announce that Rails 4.2.5.rc1 and 4.1.14.rc1 have been released.

If no regressions are found expect the final release this Wednesday, on November 4, 2015. If you find one, please open an issue on GitHub and mention me (@rafaelfranca) on it, so that we can fix it before the final release.

CHANGES since 4.1.13

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

Full listing

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

CHANGES since 4.2.4

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

Full listing

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

SHA-1

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

Here are the checksums for 4.1.14.rc1:

$ shasum *4.1.14.rc1*
6c4513c4f2a57d11fe8e9abafacde175a284a0fc  actionmailer-4.1.14.rc1.gem
27eeb9c788be0323eb459edda2b4d09418f37c40  actionpack-4.1.14.rc1.gem
2f70d52109b8be2c2dfbc57992fb1070a3a49fc5  actionview-4.1.14.rc1.gem
d3aafc6b61999fa0c9a363dfc626c93df9e460a2  activemodel-4.1.14.rc1.gem
55ea63bcca5925652956d194e8dbf4aca1780888  activerecord-4.1.14.rc1.gem
f771aa7d47c8a390449f577024d9335f7487294e  activesupport-4.1.14.rc1.gem
b3a16b8372ec44927196d38a12cc72fc97ad54c8  rails-4.1.14.rc1.gem
f1be582957f2494e13462f464e28afbaf938d233  railties-4.1.14.rc1.gem

Here are the checksums for 4.2.5.rc1:

$ shasum *4.2.5.rc1*
95125668842661dda2db412a45226f9b1219b522  actionmailer-4.2.5.rc1.gem
d9c6b7e38f9eab5975ca2549cb88b6700a0acdfd  actionpack-4.2.5.rc1.gem
f40ad9c7a5cd2c4b14f96615fdf5627d4fcaa9f3  actionview-4.2.5.rc1.gem
edcc197c162d64d663cf1049851105777c9a41ff  activejob-4.2.5.rc1.gem
eff7203c26da06c76a667428c70dc8741afac67e  activemodel-4.2.5.rc1.gem
c719ffeaffbd0f3bc1e23ed1db32df84662c0460  activerecord-4.2.5.rc1.gem
311d02a075d1669eba52b026ac60b834e02e96c6  activesupport-4.2.5.rc1.gem
810f02ff2930062f269340bc7df4e4e213a168a3  rails-4.2.5.rc1.gem
e7f842b19b4e3f67625d3df3127ed99392f19bed  railties-4.2.5.rc1.gem

I’d like to thank you all, every contributor who helped with this release.

Matthew joins Rails core; José joins Rails alumni

Please join us in welcoming Matthew Draper to the Rails core team!

Matthew is a kick-ass collaborator. He’s gone above and beyond PRs and technical contributions (which are sharp and on-point) by mentoring student groups, by coaching beginning Rails developers through their first apps alongside experienced developers working through design decisions & tradeoffs, by volunteering forserving on the Rails security team, and by emerging as a natural steward of the Rails way. His mindfulness for programmer experience & happiness puts Rails—the framework and our community—in good hands. Welcome, Matthew! 👏

Also, please join us in ushering José Valim into the halls of Rails alumni. José was once a Rails patch monster without peer, and has gone on to create the Elixir programming language and build a fantastic community around it. Gratefully, for everything: Thank you, José. ❤️

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!

Google Summer of Code 2015: Wrapping Up

This year marked our fourth participation in Google’s Summer of Code (GSoC). In this post we’d like to tell you a bit about this year’s projects:

Asset Source Maps (Andrei Istratii)

Andrei has added support for several types of Source Maps to Sprockets 4. With Source Maps users can see a readable version of their code inside Developer Tools (Javascript, CSS, etc.) after it’s been minified or compiled. Check out Andrei’s sprockets and sass-rails contributions to find out more about the project status.

Test Failure Prediction (Genki Sugimoto)

Inspired by Aaron Patterson’s ideas on testing, Genki Sugimoto created a testing library called ttnt. It tells you which tests are relevant to a particular commit inside your application, giving you the option of skipping full test-suite runs.

Web Console (Hiroyuki Sano)

The Rails Web Console helps Rails developers debug running applications inside the browser. This project was created in 2013 by Genadi Samokovarov as part of that year’s GSoC. In 2015 Hiroyuki Sano improved it by creating a browser extension so you can use the console inside the Developer Tools.

Performance Enhancements for the Asset Pipeline (Martha De Luque)

Martha focused on finding and addressing performance issues inside our asset generation pipeline. With her work we now have support for faster asset compilation libraries, and thanks to her benchmarks we now know where to focus future optimization efforts.

Evented File System Monitoring (Puneet Agarwal)

Rails monitors application files when running in development mode, if any change is detected the application code is reloaded on the next request. Currently Rails walks the application tree to detect said changes, Puneet’s contribution implements an alternative using native operating system events.

Siddharth worked on laying the infrastructure for a more robust implementation of cookies in Rails. Some of his changes include support for JSON Web Encryption (JWE) and JSON Web Signatures (JWS). With these changes in place we can add cool features like cookie purposes and coherent expiration.

Wrapping Up

We want to thank all the students and mentors involved in this year’s Summer of Code, we hope it was a good experience for everyone. We also want to thank Google for supporting the projects, and José Valim, Pat Shaughnessy and O’Reilly Media for helping out with learning resources for our students.

See you next year!

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.