Latest in branch 4.1
4.1.16
Released 12 Jul 2016
(9 years ago)
SoftwareRuby on Rails
Version4.1
Status
End of life
Initial release4.1.0
08 Apr 2014
(12 years ago)
Latest release4.1.16
12 Jul 2016
(9 years ago)
End of bug fixesUnavailable
End of security fixesUnavailable
Release noteshttps://github.com/rails/rails/releases/tag/v4.1.16
Source codehttps://github.com/rails/rails/tree/v4.1.16
Downloadhttps://github.com/rails/rails/releases/tag/v4.1.16
Ruby on Rails 4.1 ReleasesView full list

What Is New in Ruby on Rails 4.1

Category Highlights
New Features Spring preloader, config/secrets.yml, Action Pack variants, Mailer previews, Active Record enums, Message verifiers, Module#concerning, enhanced CSRF protection for JS responses
Improvements Automatic test schema maintenance, BACKTRACE env var, MiddlewareStack#unshift, Rails.gem_version helper, render :plain/:html/:body, session#fetch, deep munge opt-out, cookie serializer option
Breaking Changes CSRF protection now blocks GET .js requests, removal of deprecated rake tasks and config.whiny_nils, eliminated Rails.application.railties.engines, updated ActionController constants
Deprecations Removed update:application_controller task, thread-safe config, many Active Record and Action Pack APIs, MultiJSON dependency, several core extensions (e.g., String#encoding_aware?, Time#time_with_datetime_fallback)

How does Spring improve the Rails development workflow?

Spring keeps a preloaded copy of your application in memory so commands start instantly.

In practice you run the same binstubs you already use, but they now delegate to Spring when it's running:

$ bin/rails console
$ bin/rake test:models
$ bin/spring status

This matters if you run tests or migrations frequently; the typical 2-second boot time drops to sub-second latency. Watch out for stale code after gem changes - restart Spring with bin/spring stop.

How are secrets managed with config/secrets.yml?

Rails 4.1 introduces a dedicated config/secrets.yml file for storing secret_key_base and any other credentials.

Example file:

development:
  secret_key_base: 3b7cd727ee24e8444053437c36cc66c3
  some_api_key: SOMEKEY

You access them via Rails.application.secrets.some_api_key. This matters if you previously kept API keys in initializers; moving them centralises secret handling and works seamlessly with the encrypted credentials workflow in later Rails versions.

How can I render device-specific templates with Action Pack variants?

Variants let you serve different view files based on a request attribute such as user-agent.

Set the variant in a controller filter:

before_action do
  request.variant = :tablet if request.user_agent =~ /iPad/
end

Then respond to the variant just like a format:

respond_to do |format|
  format.html do |html|
    html.tablet   # renders show.html+tablet.erb
    html.phone { render :mobile }
  end
end

Place the files side-by-side (e.g., show.html.erb, show.html+tablet.erb, show.html+phone.erb). Most teams use this for responsive designs that need separate markup for tablets versus phones.

How do Mailer previews let me see emails without sending them?

Action Mailer previews expose a special route that renders the email body in the browser.

Create a preview class under test/mailers/previews:

class NotifierPreview < ActionMailer::Preview
  def welcome
    Notifier.welcome(User.first)
  end
end

Visit http://localhost:3000/rails/mailers/notifier/welcome to see the rendered email. This matters for design reviews and QA because you can iterate on templates without polluting real inboxes.

How do Active Record enums simplify status fields?

Enums map symbolic names to integer columns, giving you query methods and scopes automatically.

Define an enum in a model:

class Conversation < ActiveRecord::Base
  enum status: [:active, :archived]
end

Now you can call conversation.archived!, check conversation.active?, and use Conversation.archived as a scope. The underlying column stores 0 or 1, which is efficient for indexing. This matters when you need a clean, type-safe way to handle state machines without a separate gem.

Frequently Asked Questions

Do I need to modify my existing binstubs to use Spring?
No, new Rails 4.1 apps ship with "springified" binstubs, and you can run bin/rails or bin/rake as before.

Can I keep secrets out of version control?
Yes, you can use environment variables in secrets.yml by referencing <%= ENV['API_KEY'] %> so the file contains no raw credentials.

Will variants break existing HTML responses?
They add new template lookup paths but fall back to the default .html.erb if no variant file exists.

Is the mailer preview route available in production?
By default it is only mounted in the development environment; you can enable it in production by adding the route manually.

What happens if I assign an invalid value to an enum?
Active Record will raise an ArgumentError indicating the value is not a valid enum key.

Do I need to restart Spring after changing a model?
Yes, run bin/spring stop or let Spring detect the change; otherwise you may see stale schema errors.

Releases In Branch 4.1

VersionRelease date
4.1.1612 Jul 2016
(9 years ago)
4.1.16.rc101 Jul 2016
(9 years ago)
4.1.1507 Mar 2016
(10 years ago)
4.1.15.rc101 Mar 2016
(10 years ago)
4.1.14.229 Feb 2016
(10 years ago)
4.1.14.125 Jan 2016
(10 years ago)
4.1.1412 Nov 2015
(10 years ago)
4.1.14.rc205 Nov 2015
(10 years ago)
4.1.14.rc130 Oct 2015
(10 years ago)
4.1.1324 Aug 2015
(10 years ago)
4.1.13.rc114 Aug 2015
(10 years ago)
4.1.1225 Jun 2015
(10 years ago)
4.1.12.rc122 Jun 2015
(10 years ago)
4.1.1116 Jun 2015
(10 years ago)
4.1.1019 Mar 2015
(11 years ago)
4.1.10.rc412 Mar 2015
(11 years ago)
4.1.10.rc302 Mar 2015
(11 years ago)
4.1.10.rc225 Feb 2015
(11 years ago)
4.1.10.rc120 Feb 2015
(11 years ago)
4.1.906 Jan 2015
(11 years ago)
4.1.9.rc101 Jan 2015
(11 years ago)
4.1.7.119 Nov 2014
(11 years ago)
4.1.817 Nov 2014
(11 years ago)
4.1.729 Oct 2014
(11 years ago)
4.1.611 Sep 2014
(11 years ago)
4.1.6.rc208 Sep 2014
(11 years ago)
4.1.6.rc119 Aug 2014
(11 years ago)
4.1.518 Aug 2014
(11 years ago)
4.1.402 Jul 2014
(11 years ago)
4.1.302 Jul 2014
(11 years ago)
4.1.226 Jun 2014
(11 years ago)
4.1.2.rc323 Jun 2014
(11 years ago)
4.1.2.rc216 Jun 2014
(11 years ago)
4.1.2.rc127 May 2014
(12 years ago)
4.1.106 May 2014
(12 years ago)
4.1.008 Apr 2014
(12 years ago)
4.1.0.rc225 Mar 2014
(12 years ago)
4.1.0.rc118 Feb 2014
(12 years ago)
4.1.0.beta218 Feb 2014
(12 years ago)
4.1.0.beta117 Dec 2013
(12 years ago)