Ruby on Rails 5.1.0 Deprecations

With Ruby on Rails 5.1.0 RC1 out now, its official release is probably right around the corner. In efforts to clean up some of the code base, some methods have been deprecated. If you have been keeping your apps up to date with the latest stable releases, chances are that you have noticed these for some time coming as the via the deprecation notices in the application logs.

For easy searching purposes, I’ve parsed through the logs of all of the upcoming deprecations in Ruby on Rails 5.1.0. These were taken straight out of the CHANGELOGs.

Check out https://www.driftingruby.com/episodes/ruby-on-rails-5-1-0-changes-and-new-features for a screencast of some of the upcoming features in Ruby on Rails 5.1.0.

Action Pack

https://github.com/rails/rails/blob/v5.1.0.rc1/actionpack/CHANGELOG.md

Removed Deprecations

  • Remove deprecated .to_prepare, .to_cleanup, .prepare! and .cleanup! from ActionDispatch::Reloader.
  • Remove deprecated ActionDispatch::Callbacks.to_prepare and ActionDispatch::Callbacks.to_cleanup.
  • Remove deprecated ActionController::Metal.call.
  • Remove deprecated ActionController::Metal#env.
  • Remove deprecated support to non-keyword arguments in ActionDispatch::IntegrationTest#process, #get, #post, #patch, #put, #delete, and #head.
  • Remove deprecated ActionDispatch::IntegrationTest#*_via_redirect.
  • Remove deprecated ActionDispatch::IntegrationTest#xml_http_request.
  • Remove deprecated support for passing :path and route path as strings in ActionDispatch::Routing::Mapper#match.
  • Remove deprecated support for passing path as nil in ActionDispatch::Routing::Mapper#match.
  • Remove deprecated cache_control argument from ActionDispatch::Static#initialize.
  • Remove deprecated support to passing strings or symbols to the middleware stack.
  • Remove deprecated host and port ssl options.
  • Remove deprecated const_error argument in ActionDispatch::Session::SessionRestoreError#initialize.
  • Remove deprecated #original_exception in ActionDispatch::Session::SessionRestoreError.
  • Remove deprecated ActionDispatch::ParamsParser.
  • Remove deprecated original_exception and message arguments inActionDispatch::ParamsParser::ParseError#initialize.
  • Remove deprecated #original_exception in ActionDispatch::ParamsParser::ParseError.
  • Remove deprecated access to mime types through constants.
  • Remove deprecated support to non-keyword arguments in ActionController::TestCase#process, #get, #post, #patch, #put, #delete, and #head.
  • Remove deprecated xml_http_request and xhr methods in ActionController::TestCase.
  • Remove deprecated methods in ActionController::Parameters.
  • Remove deprecated support to comparing a ActionController::Parameters with a Hash.
  • Remove deprecated support to :text in render.
  • Remove deprecated support to :nothing in render.
  • Remove deprecated support to :back in redirect_to.
  • Remove deprecated support to passing status as option head.
  • Remove deprecated support to passing original exception to ActionController::BadRequest and the ActionController::BadRequest#original_exception method.
  • Remove deprecated methods skip_action_callback, skip_filter, before_filter, prepend_before_filter, skip_before_filter, append_before_filter, around_filter prepend_around_filter, skip_around_filter, append_around_filter, after_filter, prepend_after_filter, skip_after_filter and append_after_filter.

New Deprecations

  • Deprecate ActionDispatch::ParamsParser::ParseError in favor ofActionDispatch::Http::Parameters::ParseError.

ActionView

https://github.com/rails/rails/blob/v5.1.0.rc1/actionview/CHANGELOG.md

Removed Deprecations

  • Removed deprecated #original_exception in ActionView::Template::Error.

New Deprecations

  • Deprecation: The Erubis handler will be removed in Rails 5.2, for the handful of folks using it directly.

ActiveModel

https://github.com/rails/rails/blob/v5.1.0.rc1/activemodel/CHANGELOG.md

Removed Deprecations

  • Remove deprecated behavior that halts callbacks when the return is false.
  • Remove unused ActiveModel::TestCase class.
  • Removed deprecated :tokenizer in the length validator.
  • Removed deprecated methods in ActiveModel::Errors.#get, #set, []=, add_on_empty and add_on_blank.

ActiveRecord

https://github.com/rails/rails/blob/v5.1.0.rc1/activerecord/CHANGELOG.md

Removed Deprecations

  • Remove deprecated behavior that halts callbacks when the return is false.
  • Remove deprecated tasks: db:test:clone, db:test:clone_schema, db:test:clone_structure.
  • Remove deprecated #uniq, #uniq!, and #uniq_value.
  • Remove deprecated #insert_sql, #update_sql, and #delete_sql.
  • Remove deprecated #use_transactional_fixtures configuration.
  • Remove deprecated #raise_in_transactional_callbacks configuration.
  • Remove deprecated #load_schema_for.
  • Remove deprecated conditions parameter from #destroy_all and #delete_all.
  • Remove deprecated support to passing arguments to #select when a block is provided.
  • Remove deprecated support to query using commas on LIMIT.
  • Remove deprecated support to passing a class as a value in a query.
  • Remove deprecated original_exception argument in ActiveRecord::StatementInvalid#initialize and ActiveRecord::StatementInvalid#original_exception.
  • #tables and #table_exists? return only tables and not views.All the deprecations on those methods were removed.
  • Remove deprecated name argument from #tables.
  • Remove deprecated support to passing a column to #quote.
  • Remove deprecated force reload argument in singular and collection association readers.
  • Remove deprecated activerecord.errors.messages.restrict_dependent_destroy.one and activerecord.errors.messages.restrict_dependent_destroy.many i18n scopes.

New Deprecations

  • Deprecate Migrator.schema_migrations_table_name.
  • Deprecate supports_migrations? on connection adapters.
  • Deprecate using #quoted_id in quoting.
  • Deprecate passing default to index_name_exists?.
  • Deprecate supports_primary_key? on connection adapters since it’s been long unused and unsupported.
  • Deprecate locking records with unpersisted changes.
  • Deprecate ColumnDumper#migration_keys.
  • Deprecate initialize_schema_migrations_table and initialize_internal_metadata_table.
  • Deprecate passing a class to the class_name because it eagerloads more classes than necessary and potentially creates circular dependencies.
  • Deprecate passing name to indexes.
  • Deprecate passing arguments and block at the same time to ActiveRecord::QueryMethods#select.
  • Deprecate sanitize_conditions. Use sanitize_sql instead.

ActiveSupport

https://github.com/rails/rails/blob/v5.1.0.rc1/activesupport/CHANGELOG.md

Removed Deprecations

  • Remove deprecated behavior that halts callbacks when the return is false.
  • Remove deprecated class ActiveSupport::Concurrency::Latch.
  • Remove deprecated separator argument from parameterize.
  • Remove deprecated method Numeric#to_formatted_s.
  • Remove deprecated method alias_method_chain.
  • Remove deprecated constant MissingSourceFile.
  • Remove deprecated methods Module.qualified_const_defined?, Module.qualified_const_get and Module.qualified_const_set.
  • Remove deprecated :prefix option from number_to_human_size.
  • Remove deprecated method ActiveSupport::HashWithIndifferentAccess.new_from_hash_copying_default.
  • Remove deprecated file active_support/core_ext/time/marshal.rb.
  • Remove deprecated file active_support/core_ext/struct.rb.
  • Remove deprecated file active_support/core_ext/module/method_transplanting.rb.
  • Remove deprecated method Module.local_constants.
  • Remove deprecated file active_support/core_ext/kernel/debugger.rb.
  • Remove deprecated method ActiveSupport::Cache::Store#namespaced_key.
  • Remove deprecated method ActiveSupport::Cache::Strategy::LocalCache::LocalStore#set_cache_value.
  • Remove deprecated method ActiveSupport::Cache::MemCacheStore#escape_key.
  • Remove deprecated method ActiveSupport::Cache::FileStore#key_file_path.
  • Remove deprecated arguments in assert_nothing_raised.

New Deprecations

  • Deprecate implicit coercion of ActiveSupport::DurationCurrently ActiveSupport::Duration implicitly converts to a seconds value when used in a calculation except for the explicit examples of addition and subtraction where the duration is the receiver, e.g:

    This results in lots of confusion especially when using durations with dates because adding/subtracting a value from a date treats integers as a day and not a second, e.g:

    To fix this we’re implementing coerce so that we can provide a deprecation warning with the intent of removing the implicit coercion in Rails 5.2, e.g:

    In Rails 5.2 it will raise TypeError, e.g:

    This is the same behavior as with other types in Ruby, e.g:

    As part of this deprecation add * and / methods to AS::Duration so that calculations that keep the duration as the receiver work correctly whether the final receiver is a Date or Time, e.g:

    Fixes #27457.
  • Soft-deprecated the top-level HashWithIndifferentAccess constant.ActiveSupport::HashWithIndifferentAccess should be used instead.Fixes #28157.
  • Deprecate ActiveSupport.halt_callback_chains_on_return_false.
  • Deprecate passing string to :if and :unless conditional options on set_callback and skip_callback.

ActiveJob

https://github.com/rails/rails/blob/v5.1.0.rc1/activejob/CHANGELOG.md

Removed Deprecations

  • Removed deprecated support to passing the adapter class to .queue_adapter.
  • Removed deprecated #original_exception in ActiveJob::DeserializationError.

New Deprecations

  • None

Railsties

https://github.com/rails/rails/blob/v5.1.0.rc1/railties/CHANGELOG.md

Removed Deprecations

  • Remove deprecated CONTROLLER environment variable for routes task.
  • Remove deprecated tasks: rails:update, rails:template, rails:template:copy, rails:update:configs and rails:update:bin.
  • Remove deprecated file rails/rack/debugger.
  • Remove deprecated config.serve_static_files.
  • Remove deprecated config.static_cache_control.
  • Removed jquery-rails from default stack, instead rails-ujs that is shipped with Action View is included as default UJS adapter.

New Deprecations

  • None