Latest in branch 5.1
5.1.7
Released 27 Mar 2019
(7 years ago)
SoftwareRuby on Rails
Version5.1
Status
End of life
Initial release5.1.0
27 Apr 2017
(9 years ago)
Latest release5.1.7
27 Mar 2019
(7 years ago)
End of bug fixes09 Apr 2018
(Ended 8 years, 1 month ago)
End of security fixes25 Aug 2019
(Ended 6 years, 9 months ago)
Release noteshttps://github.com/rails/rails/releases/tag/v5.1.7
Source codehttps://github.com/rails/rails/tree/v5.1.7
Downloadhttps://github.com/rails/rails/releases/tag/v5.1.7
Ruby on Rails 5.1 ReleasesView full list

What Is New in Ruby on Rails 5.1

Category Highlights
New Features Yarn integration for npm packages, optional Webpacker via the --webpack flag, rails-ujs replaces jQuery as the default UJS adapter, built-in System test support with Capybara, encrypted secrets management, parameterized mailers, new routing helpers direct and resolve, unified form_with helper.
Improvements Unified form handling reduces API surface, default UJS now vanilla JS, ActiveSupport duration helpers gain #before and #after, ActiveJob adds declarative retry_on and discard_on, ActiveRecord primary keys default to BIGINT, better batch limits and connection-pool stats.
Breaking Changes Transactional tests now wrap *all* DB connections, jQuery-rails removed from the default stack, deprecated config.static_cache_control and config.serve_static_files eliminated, old Rails tasks (rails:update, rails:template etc.) removed, -j option dropped from rails new, integration test methods no longer accept non-keyword arguments, removed :text and :nothing render options, HashWithIndifferentAccess methods on ActionController::Parameters gone.
Deprecations config.action_controller.raise_on_unfiltered_parameters is now a no-op, Erubis ERB handler deprecated in favor of Erubi, top-level HashWithIndifferentAccess class soft-deprecated, string arguments for :if/:unless in callbacks deprecated, several ActiveRecord and ActiveJob APIs marked deprecated.

How does Rails 5.1 change JavaScript asset management?

Rails 5.1 introduces Yarn for npm package management and makes Webpacker optional via the --webpack flag.

  • Yarn is now generated in new apps with a package.json and a binstub, letting you pull in libraries such as React or Vue directly from npm.
  • Webpacker integrates seamlessly with the asset pipeline; you can keep images, fonts, and legacy JavaScript in app/assets while bundling modern JavaScript through Webpack.
  • jQuery is no longer a default dependency; the new rails-ujs driver ships with Action View and works out-of-the-box for data-remote and data-confirm attributes.
# Example: adding a library with Yarn
yarn add axios
# Then import in app/javascript/packs/application.js
import axios from 'axios'

What testing capabilities are built into Rails 5.1?

Rails 5.1 adds first-class System tests powered by Capybara and updates transactional test handling.

  • Generate a system test with rails generate system_test example; Rails configures Capybara, a headless Chrome driver, and automatic screenshot capture on failures.
  • All Active Record connections now share the same transaction during tests, preventing flaky data visibility when spawning threads.
  • If you rely on separate connections in threaded tests, you can disable the new behavior by turning off use_transactional_tests for the affected test case.

How are application secrets stored securely in Rails 5.1?

Rails 5.1 provides encrypted secrets that keep credentials out of source control.

  • Run bin/rails secrets:setup to generate config/secrets.yml.enc and a master key.
  • The master key must be stored outside the repository (e.g., in RAILS_MASTER_KEY env var or a separate master.key file).
  • At runtime Rails decrypts the file automatically, so you can safely commit the encrypted version.
# config/secrets.yml.enc (encrypted)
production:
  secret_key_base: <encrypted>

What changes affect form handling and routing in Rails 5.1?

Rails 5.1 unifies form helpers with form_with and adds new routing DSL methods direct and resolve.

  • form_with replaces form_for and form_tag, automatically inferring URLs from models or accepting explicit url and scope options.
  • Use direct to create custom URL helpers that return any url_for-compatible value.
  • Use resolve to customize polymorphic routing, e.g., mapping a Basket model to a singular /basket path.
# Example: custom helper
direct(:homepage) { "https://rubyonrails.org" }
# Usage
homepage_url # => "https://rubyonrails.org"

Frequently Asked Questions

Do I need to install Yarn manually before creating a new Rails 5.1 app?
You can rely on the Yarn binstub generated by rails new, but having Yarn installed globally is recommended.

Is jQuery completely removed from Rails 5.1?
jQuery is no longer included by default; you can still add it via Yarn if your code depends on it.

How do I enable Webpacker in an existing Rails 5.0 project?
Add the webpacker gem to your Gemfile and run bundle exec rails webpacker:install to set up the configuration.

Can I run System tests without a Chrome browser installed?
Rails defaults to headless Chrome, but you can configure Capybara to use Selenium with Firefox if needed.

What command creates the encrypted secrets file?
Run bin/rails secrets:setup to generate config/secrets.yml.enc and a master key.

Will my existing integration tests break because of the non-keyword argument removal?
Yes, you must update calls like get :show, id: 1 to the keyword style get :show, params: { id: 1 }.

Releases In Branch 5.1

VersionRelease date
5.1.727 Mar 2019
(7 years ago)
5.1.7.rc122 Mar 2019
(7 years ago)
5.1.6.213 Mar 2019
(7 years ago)
5.1.6.127 Nov 2018
(7 years ago)
5.1.629 Mar 2018
(8 years ago)
5.1.514 Feb 2018
(8 years ago)
5.1.5.rc101 Feb 2018
(8 years ago)
5.1.408 Sep 2017
(8 years ago)
5.1.4.rc124 Aug 2017
(8 years ago)
5.1.303 Aug 2017
(8 years ago)
5.1.3.rc331 Jul 2017
(8 years ago)
5.1.3.rc225 Jul 2017
(8 years ago)
5.1.3.rc119 Jul 2017
(8 years ago)
5.1.226 Jun 2017
(8 years ago)
5.1.2.rc120 Jun 2017
(8 years ago)
5.1.112 May 2017
(9 years ago)
5.1.027 Apr 2017
(9 years ago)
5.1.0.rc220 Apr 2017
(9 years ago)
5.1.0.rc120 Mar 2017
(9 years ago)
5.1.0.beta123 Feb 2017
(9 years ago)