Fixture files are passed through an ERB renderer before being read as YAML. The rendering is currently done in the context of the main object, so method definitons leak into other fixtures, and there is no clean place to define fixture helpers. After this commit, the ERB renderer will use a new subclass of ActiveRecord::FixtureSet.context_class each time a fixture is rendered.
13 KiB
Ruby on Rails 4.1 Release Notes
Highlights in Rails 4.1:
- Action View extracted from Action Pack
These release notes cover only the major changes. To know about various bug fixes and changes, please refer to the change logs or check out the list of commits in the main Rails repository on GitHub.
Upgrading to Rails 4.1
If you're upgrading an existing application, it's a great idea to have good test coverage before going in. You should also first upgrade to Rails 4.0 in case you haven't and make sure your application still runs as expected before attempting an update to Rails 4.1. A list of things to watch out for when upgrading is available in the Upgrading to Rails guide.
Major Features
Documentation
Railties
Please refer to the Changelog for detailed changes.
Removals
-
Removed
update:application_controller
rake task. -
Removed deprecated
Rails.application.railties.engines
. -
Removed deprecated
threadsafe!
from Rails Config. -
Removed deprecated
ActiveRecord::Generators::ActiveModel#update_attributes
in favor ofActiveRecord::Generators::ActiveModel#update
-
Removed deprecated
config.whiny_nils
option -
Removed deprecated rake tasks for running tests:
rake test:uncommitted
andrake test:recent
.
Notable changes
-
BACKTRACE
environment variable to show unfiltered backtraces for test failures. (Commit) -
Exposed
MiddlewareStack#unshift
to environment configuration. (Pull Request)
Action Mailer
Please refer to the Changelog for detailed changes.
Notable changes
- Instrument the generation of Action Mailer messages. The time it takes to generate a message is written to the log. (Pull Request)
Active Model
Please refer to the Changelog for detailed changes.
Deprecations
- Deprecate
Validator#setup
. This should be done manually now in the validator's constructor. (Commit)
Notable changes
- Added new API methods
reset_changes
andchanges_applied
toActiveModel::Dirty
that control changes state.
Active Support
Please refer to the Changelog for detailed changes.
Removals
-
Removed deprecated
String#encoding_aware?
core extensions (core_ext/string/encoding
). -
Removed deprecated
Module#local_constant_names
in favor ofModule#local_constants
. -
Removed deprecated
DateTime.local_offset
in favor ofDateTime.civil_from_fromat
. -
Removed deprecated
Logger
core extensions (core_ext/logger.rb
). -
Removed deprecated
Time#time_with_datetime_fallback
,Time#utc_time
andTime#local_time
in favor ofTime#utc
andTime#local
. -
Removed deprecated
Hash#diff
with no replacement. -
Removed deprecated
Date#to_time_in_current_zone
in favor ofDate#in_time_zone
. -
Removed deprecated
Proc#bind
with no replacement. -
Removed deprecated
Array#uniq_by
andArray#uniq_by!
, use nativeArray#uniq
andArray#uniq!
instead. -
Removed deprecated
ActiveSupport::BasicObject
, useActiveSupport::ProxyObject
instead. -
Removed deprecated
BufferedLogger
, useActiveSupport::Logger
instead. -
Removed deprecated
assert_present
andassert_blank
methods, useassert object.blank?
andassert object.present?
instead.
Deprecations
- Deprecated
Numeric#{ago,until,since,from_now}
, the user is expected to explicitly convert the value into an AS::Duration, i.e.5.ago
=>5.seconds.ago
(Pull Request)
Notable changes
-
Added
ActiveSupport::Testing::TimeHelpers#travel
and#travel_to
. These methods change current time to the given time or time difference by stubbingTime.now
andDate.today
. (Pull Request) -
Added
Numeric#in_milliseconds
, like1.hour.in_milliseconds
, so we can feed them to JavaScript functions likegetTime()
. (Commit) -
Added
Date#middle_of_day
,DateTime#middle_of_day
andTime#middle_of_day
methods. Also addedmidday
,noon
,at_midday
,at_noon
andat_middle_of_day
as aliases. (Pull Request) -
Added
String#remove(pattern)
as a short-hand for the common pattern ofString#gsub(pattern,'')
. (Commit) -
Removed 'cow' => 'kine' irregular inflection from default inflections. (Commit)
Action Pack
Please refer to the Changelog for detailed changes.
Removals
-
Removed deprecated Rails application fallback for integration testing, set
ActionDispatch.test_app
instead. -
Removed deprecated
page_cache_extension
config. -
Removed deprecated constants from Action Controller:
ActionController::AbstractRequest => ActionDispatch::Request ActionController::Request => ActionDispatch::Request ActionController::AbstractResponse => ActionDispatch::Response ActionController::Response => ActionDispatch::Response ActionController::Routing => ActionDispatch::Routing ActionController::Integration => ActionDispatch::Integration ActionController::IntegrationTest => ActionDispatch::IntegrationTest
Notable changes
-
Take a hash with options inside array in
#url_for
. (Pull Request) -
Added
session#fetch
method fetch behaves similarly to Hash#fetch, with the exception that the returned value is always saved into the session. (Pull Request) -
Separated Action View completely from Action Pack. (Pull Request)
Active Record
Please refer to the Changelog for detailed changes.
Removals
-
Removed deprecated nil-passing to the following
SchemaCache
methods:primary_keys
,tables
,columns
andcolumns_hash
. -
Removed deprecated block filter from
ActiveRecord::Migrator#migrate
. -
Removed deprecated String constructor from
ActiveRecord::Migrator
. -
Removed deprecated
scope
use without passing a callable object. -
Removed deprecated
transaction_joinable=
in favor ofbegin_transaction
withd:joinable
option. -
Removed deprecated
decrement_open_transactions
. -
Removed deprecated
increment_open_transactions
. -
Removed deprecated
PostgreSQLAdapter#outside_transaction?
methodd. You can use#transaction_open?
instead. -
Removed deprecated
ActiveRecord::Fixtures.find_table_name
in favor ofActiveRecord::Fixtures.default_fixture_model_name
. -
Removed deprecated
columns_for_remove
fromSchemaStatements
. -
Removed deprecated
SchemaStatements#distinct
. -
Moved deprecated
ActiveRecord::TestCase
into the rails test suite. The class is no longer public and is only used for internal Rails tests. -
Removed support for deprecated option
:restrict
for:dependent
in associations. -
Removed support for deprecated
delete_sql
in associations. -
Removed support for deprecated
insert_sql
in associations. -
Removed support for deprecated
finder_sql
in associations. -
Removed support for deprecated
counter_sql
in associations. -
Removed deprecated method
type_cast_code
from Column. -
Removed deprecated options
delete_sql
andinsert_sql
from HABTM association. -
Removed deprecated options
finder_sql
andcounter_sql
from collection association. -
Removed deprecated
ActiveRecord::Base#connection
method. Make sure to access it via the class. -
Removed deprecation warning for
auto_explain_threshold_in_seconds
. -
Removed deprecated
:distinct
option fromRelation#count
. -
Removed deprecated methods
partial_updates
,partial_updates?
andpartial_updates=
. -
Removed deprecated method
scoped
-
Removed deprecated method
default_scopes?
-
Remove implicit join references that were deprecated in 4.0.
-
Removed
activerecord-deprecated_finders
as a dependency -
Usage of
implicit_readonly
is being removed. Please usereadonly
method explicitly to mark records as `readonly. (Pull Request)
Deprecations
-
Deprecated
quoted_locking_column
method, which isn't used anywhere. -
Deprecated the delegation of Array bang methods for associations. To use them, instead first call
#to_a
on the association to access the array to be acted on. (Pull Request) -
Deprecated
ConnectionAdapters::SchemaStatements#distinct
, as it is no longer used by internals. (Pull Request)
Notable changes
-
Added
ActiveRecord::Base.to_param
for convenient "pretty" URLs derived from a model's attribute or method. (Pull Request) -
Added
ActiveRecord::Base.no_touching
, which allows ignoring touch on models. (Pull Request) -
Unify boolean type casting for
MysqlAdapter
andMysql2Adapter
.type_cast
will return1
fortrue
and0
forfalse
. (Pull Request) -
.unscope
now removes conditions specified indefault_scope
. (Commit) -
Added
ActiveRecord::QueryMethods#rewhere
which will overwrite an existing, named where condition. (Commit) -
Extended
ActiveRecord::Base#cache_key
to take an optional list of timestamp attributes of which the highest will be used. (Commit) -
Added
ActiveRecord::Base#enum
for declaring enum attributes where the values map to integers in the database, but can be queried by name. (Commit) -
Type cast json values on write, so that the value is consistent with reading from the database. (Pull Request)
-
Type cast hstore values on write, so that the value is consistent with reading from the database. (Commit)
-
Make
next_migration_number
accessible for third party generators. (Pull Request) -
Calling
update_attributes
will now throw anArgumentError
whenever it gets anil
argument. More specifically, it will throw an error if the argument that it gets passed does not respond to tostringify_keys
. (Pull Request) -
CollectionAssociation#first
/#last
(e.g.has_many
) use aLIMIT
ed query to fetch results rather than loading the entire collection. (Pull Request) -
inspect
on Active Record model classes does not initiate a new connection. This means that callinginspect
, when the database is missing, will no longer raise an exception. (Pull Request) -
Removed column restrictions for
count
, let the database raise if the SQL is invalid. (Pull Request) -
Rails now automatically detects inverse associations. If you do not set the
:inverse_of
option on the association, then Active Record will guess the inverse association based on heuristics. (Pull Request) -
Handle aliased attributes in ActiveRecord::Relation. When using symbol keys, ActiveRecord will now translate aliased attribute names to the actual column name used in the database. (Pull Request)
-
The ERB in fixture files is no longer evaluated in the context of the main object. Helper methods used by multiple fixtures should be defined on modules included in
ActiveRecord::FixtureSet.context_class
. (Pull Request)
Credits
See the full list of contributors to Rails for the many people who spent many hours making Rails, the stable and robust framework it is. Kudos to all of them.