diff options
33 files changed, 102 insertions, 2791 deletions
diff --git a/.travis.yml b/.travis.yml index 2823a5456f..7adde8971e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,18 +16,12 @@ env: - "GEM=ar:postgresql" - "GEM=aj:integration" rvm: - - 1.9.3 - - 2.0.0 - 2.1 - ruby-head - rbx-2 - jruby matrix: allow_failures: - - rvm: 1.9.3 - env: "GEM=ar:mysql" - - rvm: 2.0.0 - env: "GEM=ar:mysql" - rvm: ruby-head env: "GEM=ar:mysql" - rvm: rbx-2 @@ -11,7 +11,7 @@ gem 'rake', '>= 10.3' gem 'mocha', '~> 0.14', require: false gem 'rack-cache', '~> 1.2' -gem 'jquery-rails', '~> 4.0' +gem 'jquery-rails', github: 'rails/jquery-rails' gem 'coffee-rails', '~> 4.1.0' gem 'turbolinks' @@ -47,7 +47,7 @@ group :job do gem 'backburner', require: false gem 'qu-rails', github: "bkeepers/qu", branch: "master", require: false gem 'qu-redis', require: false - gem 'delayed_job_active_record', require: false + # gem 'delayed_job_active_record', require: false gem 'sequel', require: false end diff --git a/RAILS_VERSION b/RAILS_VERSION index b86dc8c0c6..2b915d7d5c 100644 --- a/RAILS_VERSION +++ b/RAILS_VERSION @@ -1 +1 @@ -4.2.0.beta4 +5.0.0.alpha diff --git a/actionmailer/CHANGELOG.md b/actionmailer/CHANGELOG.md index c8b969c59a..88b0962e8c 100644 --- a/actionmailer/CHANGELOG.md +++ b/actionmailer/CHANGELOG.md @@ -1,63 +1 @@ -* `MailerGenerator` now generates layouts by default. The HTML mailer layout - now includes `<html>` and `<body>` tags which improve the spam rating in - some spam detection engines. Mailers now inherit from `ApplicationMailer` - which sets the default layout. - - *Andy Jeffries* - -* `link_to` and `url_for` now generate URLs by default in templates. - Passing `only_path: false` is no longer needed. - - Fixes #16497 and #16589. - - *Xavier Noria*, *Richard Schneeman* - -* Attachments can now be added while rendering the mail template. - - Fixes #16974. - - *Christian Felder* - -* Add `#deliver_later` and `#deliver_now` methods and deprecate `#deliver` in - favor of `#deliver_now`. `#deliver_later` will enqueue a job to render and - deliver the mail instead of delivering it immediately. The job is enqueued - using the new Active Job framework in Rails and will use the queue that you - have configured in Rails. - - *DHH*, *Abdelkader Boudih*, *Cristian Bica* - -* `ActionMailer::Previews` are now class methods instead of instance methods. - - *Cristian Bica* - -* Deprecate `*_path` helpers in email views. They generated broken links in - email views and were not the intention of most developers. The `*_url` - helper is recommended instead. - - *Richard Schneeman* - -* Raise an exception when attachments are added after `mail` is called. - This is a safeguard to prevent invalid emails. - - Fixes #16163. - - *Yves Senn* - -* Add `config.action_mailer.show_previews` configuration option. - - This configuration option can be used to enable the mail preview in - environments other than development (such as staging). - - Defaults to `true` in development and `false` elsewhere. - - *Leonard Garvey* - -* Allow preview interceptors to be registered through - `config.action_mailer.preview_interceptors`. - - See #15739. - - *Yves Senn* - -Please check [4-1-stable](https://github.com/rails/rails/blob/4-1-stable/actionmailer/CHANGELOG.md) -for previous changes. +Please check [4-2-stable](https://github.com/rails/rails/blob/4-2-stable/actionmailer/CHANGELOG.md) for previous changes. diff --git a/actionmailer/lib/action_mailer/gem_version.rb b/actionmailer/lib/action_mailer/gem_version.rb index e568b8f6f2..ac79788cf0 100644 --- a/actionmailer/lib/action_mailer/gem_version.rb +++ b/actionmailer/lib/action_mailer/gem_version.rb @@ -5,10 +5,10 @@ module ActionMailer end module VERSION - MAJOR = 4 - MINOR = 2 + MAJOR = 5 + MINOR = 0 TINY = 0 - PRE = "beta4" + PRE = "alpha" STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".") end diff --git a/actionpack/CHANGELOG.md b/actionpack/CHANGELOG.md index 07063c953a..556545c0d8 100644 --- a/actionpack/CHANGELOG.md +++ b/actionpack/CHANGELOG.md @@ -1,410 +1 @@ -* Restore handling of a bare `Authorization` header, without `token=` - prefix. - - Fixes #17108. - - *Guo Xiang Tan* - -* Deprecate use of string keys in URL helpers. - - Use symbols instead. - Fixes #16958. - - *Byron Bischoff*, *Melanie Gilman* - -* Deprecate the `only_path` option on `*_path` helpers. - - In cases where this option is set to `true`, the option is redundant and can - be safely removed; otherwise, the corresponding `*_url` helper should be - used instead. - - Fixes #17294. - - *Dan Olson*, *Godfrey Chan* - -* Improve Journey compliance to RFC 3986. - - The scanner in Journey failed to recognize routes that use literals - from the sub-delims section of RFC 3986. It's now able to parse those - authorized delimiters and route as expected. - - Fixes #17212. - - *Nicolas Cavigneaux* - -* Deprecate implicit Array conversion for Response objects. It was added - (using `#to_ary`) so we could conveniently use implicit splatting: - - status, headers, body = response - - But it also means `response + response` works and `[response].flatten` - cascades down to the Rack body. Nonsense behavior. Instead, rely on - explicit conversion and splatting with `#to_a`: - - status, header, body = *response - - *Jeremy Kemper* - -* Don't rescue `IPAddr::InvalidAddressError`. - - `IPAddr::InvalidAddressError` does not exist in Ruby 1.9.3 - and fails for JRuby in 1.9 mode. - - *Peter Suschlik* - -* Fix bug where the router would ignore any constraints added to redirect - routes. - - Fixes #16605. - - *Agis Anastasopoulos* - -* Allow `config.action_dispatch.trusted_proxies` to accept an IPAddr object. - - Example: - - # config/environments/production.rb - config.action_dispatch.trusted_proxies = IPAddr.new('4.8.15.0/16') - - *Sam Aarons* - -* Avoid duplicating routes for HEAD requests. - - Instead of duplicating the routes, we will first match the HEAD request to - HEAD routes. If no match is found, we will then map the HEAD request to - GET routes. - - *Guo Xiang Tan*, *Andrew White* - -* Requests that hit `ActionDispatch::Static` can now take advantage - of gzipped assets on disk. By default a gzip asset will be served if - the client supports gzip and a compressed file is on disk. - - *Richard Schneeman* - -* `ActionController::Parameters` will stop inheriting from `Hash` and - `HashWithIndifferentAccess` in the next major release. If you use any method - that is not available on `ActionController::Parameters` you should consider - calling `#to_h` to convert it to a `Hash` first before calling that method. - - *Prem Sichanugrist* - -* `ActionController::Parameters#to_h` now returns a `Hash` with unpermitted - keys removed. This change is to reflect on a security concern where some - method performed on an `ActionController::Parameters` may yield a `Hash` - object which does not maintain `permitted?` status. If you would like to - get a `Hash` with all the keys intact, duplicate and mark it as permitted - before calling `#to_h`. - - params = ActionController::Parameters.new({ - name: 'Senjougahara Hitagi', - oddity: 'Heavy stone crab' - }) - params.to_h - # => {} - - unsafe_params = params.dup.permit! - unsafe_params.to_h - # => {"name"=>"Senjougahara Hitagi", "oddity"=>"Heavy stone crab"} - - safe_params = params.permit(:name) - safe_params.to_h - # => {"name"=>"Senjougahara Hitagi"} - - This change is consider a stopgap as we cannot change the code to stop - `ActionController::Parameters` to inherit from `HashWithIndifferentAccess` - in the next minor release. - - *Prem Sichanugrist* - -* Deprecated `TagAssertions`. - - *Kasper Timm Hansen* - -* Use the Active Support JSON encoder for cookie jars using the `:json` or - `:hybrid` serializer. This allows you to serialize custom Ruby objects into - cookies by defining the `#as_json` hook on such objects. - - Fixes #16520. - - *Godfrey Chan* - -* Add `config.action_dispatch.cookies_digest` option for setting custom - digest. The default remains the same - 'SHA1'. - - *Łukasz Strzałkowski* - -* Move `respond_with` (and the class-level `respond_to`) to - the `responders` gem. - - *José Valim* - -* When your templates change, browser caches bust automatically. - - New default: the template digest is automatically included in your ETags. - When you call `fresh_when @post`, the digest for `posts/show.html.erb` - is mixed in so future changes to the HTML will blow HTTP caches for you. - This makes it easy to HTTP-cache many more of your actions. - - If you render a different template, you can now pass the `:template` - option to include its digest instead: - - fresh_when @post, template: 'widgets/show' - - Pass `template: false` to skip the lookup. To turn this off entirely, set: - - config.action_controller.etag_with_template_digest = false - - *Jeremy Kemper* - -* Remove deprecated `AbstractController::Helpers::ClassMethods::MissingHelperError` - in favor of `AbstractController::Helpers::MissingHelperError`. - - *Yves Senn* - -* Fix `assert_template` not being able to assert that no files were rendered. - - *Guo Xiang Tan* - -* Extract source code for the entire exception stack trace for - better debugging and diagnosis. - - *Ryan Dao* - -* Allows ActionDispatch::Request::LOCALHOST to match any IPv4 127.0.0.0/8 - loopback address. - - *Earl St Sauver*, *Sven Riedel* - -* Preserve original path in `ShowExceptions` middleware by stashing it as - `env["action_dispatch.original_path"]` - - `ActionDispatch::ShowExceptions` overwrites `PATH_INFO` with the status code - for the exception defined in `ExceptionWrapper`, so the path - the user was visiting when an exception occurred was not previously - available to any custom exceptions_app. The original `PATH_INFO` is now - stashed in `env["action_dispatch.original_path"]`. - - *Grey Baker* - -* Use `String#bytesize` instead of `String#size` when checking for cookie - overflow. - - *Agis Anastasopoulos* - -* `render nothing: true` or rendering a `nil` body no longer add a single - space to the response body. - - The old behavior was added as a workaround for a bug in an early version of - Safari, where the HTTP headers are not returned correctly if the response - body has a 0-length. This is been fixed since and the workaround is no - longer necessary. - - Use `render body: ' '` if the old behavior is desired. - - See #14883 for details. - - *Godfrey Chan* - -* Prepend a JS comment to JSONP callbacks. Addresses CVE-2014-4671 - ("Rosetta Flash"). - - *Greg Campbell* - -* Because URI paths may contain non US-ASCII characters we need to force - the encoding of any unescaped URIs to UTF-8 if they are US-ASCII. - This essentially replicates the functionality of the monkey patch to - URI.parser.unescape in active_support/core_ext/uri.rb. - - Fixes #16104. - - *Karl Entwistle* - -* Generate shallow paths for all children of shallow resources. - - Fixes #15783. - - *Seb Jacobs* - -* JSONP responses are now rendered with the `text/javascript` content type - when rendering through a `respond_to` block. - - Fixes #15081. - - *Lucas Mazza* - -* Add `config.action_controller.always_permitted_parameters` to configure which - parameters are permitted globally. The default value of this configuration is - `['controller', 'action']`. - - *Gary S. Weaver*, *Rafael Chacon* - -* Fix env['PATH_INFO'] missing leading slash when a rack app mounted at '/'. - - Fixes #15511. - - *Larry Lv* - -* ActionController::Parameters#require now accepts `false` values. - - Fixes #15685. - - *Sergio Romano* - -* With authorization header `Authorization: Token token=`, `authenticate` now - recognize token as nil, instead of "token". - - Fixes #14846. - - *Larry Lv* - -* Ensure the controller is always notified as soon as the client disconnects - during live streaming, even when the controller is blocked on a write. - - *Nicholas Jakobsen*, *Matthew Draper* - -* Routes specifying 'to:' must be a string that contains a "#" or a rack - application. Use of a symbol should be replaced with `action: symbol`. - Use of a string without a "#" should be replaced with `controller: string`. - - *Aaron Patterson* - -* Fix URL generation with `:trailing_slash` such that it does not add - a trailing slash after `.:format` - - *Dan Langevin* - -* Build full URI as string when processing path in integration tests for - performance reasons. - - *Guo Xiang Tan* - -* Fix `'Stack level too deep'` when rendering `head :ok` in an action method - called 'status' in a controller. - - Fixes #13905. - - *Christiaan Van den Poel* - -* Add MKCALENDAR HTTP method (RFC 4791). - - *Sergey Karpesh* - -* Instrument fragment cache metrics. - - Adds `:controller`: and `:action` keys to the instrumentation payload - for the `*_fragment.action_controller` notifications. This allows tracking - e.g. the fragment cache hit rates for each controller action. - - *Daniel Schierbeck* - -* Always use the provided port if the protocol is relative. - - Fixes #15043. - - *Guilherme Cavalcanti*, *Andrew White* - -* Moved `params[request_forgery_protection_token]` into its own method - and improved tests. - - Fixes #11316. - - *Tom Kadwill* - -* Added verification of route constraints given as a Proc or an object responding - to `:matches?`. Previously, when given an non-complying object, it would just - silently fail to enforce the constraint. It will now raise an `ArgumentError` - when setting up the routes. - - *Xavier Defrang* - -* Properly treat the entire IPv6 User Local Address space as private for - purposes of remote IP detection. Also handle uppercase private IPv6 - addresses. - - Fixes #12638. - - *Caleb Spare* - -* Fixed an issue with migrating legacy json cookies. - - Previously, the `VerifyAndUpgradeLegacySignedMessage` assumes all incoming - cookies are marshal-encoded. This is not the case when `secret_token` is - used in conjunction with the `:json` or `:hybrid` serializer. - - In those case, when upgrading to use `secret_key_base`, this would cause a - `TypeError: incompatible marshal file format` and a 500 error for the user. - - Fixes #14774. - - *Godfrey Chan* - -* Make URL escaping more consistent: - - 1. Escape '%' characters in URLs - only unescaped data should be passed to URL helpers - 2. Add an `escape_segment` helper to `Router::Utils` that escapes '/' characters - 3. Use `escape_segment` rather than `escape_fragment` in optimized URL generation - 4. Use `escape_segment` rather than `escape_path` in URL generation - - For point 4 there are two exceptions. Firstly, when a route uses wildcard segments - (e.g. `*foo`) then we use `escape_path` as the value may contain '/' characters. This - means that wildcard routes can't be optimized. Secondly, if a `:controller` segment - is used in the path then this uses `escape_path` as the controller may be namespaced. - - Fixes #14629, #14636 and #14070. - - *Andrew White*, *Edho Arief* - -* Add alias `ActionDispatch::Http::UploadedFile#to_io` to - `ActionDispatch::Http::UploadedFile#tempfile`. - - *Tim Linquist* - -* Returns null type format when format is not know and controller is using `any` - format block. - - Fixes #14462. - - *Rafael Mendonça França* - -* Improve routing error page with fuzzy matching search. - - *Winston* - -* Only make deeply nested routes shallow when parent is shallow. - - Fixes #14684. - - *Andrew White*, *James Coglan* - -* Append link to bad code to backtrace when exception is `SyntaxError`. - - *Boris Kuznetsov* - -* Swapped the parameters of assert_equal in `assert_select` so that the - proper values were printed correctly. - - Fixes #14422. - - *Vishal Lal* - -* The method `shallow?` returns false if the parent resource is a singleton so - we need to check if we're not inside a nested scope before copying the :path - and :as options to their shallow equivalents. - - Fixes #14388. - - *Andrew White* - -* Make logging of CSRF failures optional (but on by default) with the - `log_warning_on_csrf_failure` configuration setting in - `ActionController::RequestForgeryProtection`. - - *John Barton* - -* Fix URL generation in controller tests with request-dependent - `default_url_options` methods. - - *Tony Wooster* - -Please check [4-1-stable](https://github.com/rails/rails/blob/4-1-stable/actionpack/CHANGELOG.md) for previous changes. +Please check [4-2-stable](https://github.com/rails/rails/blob/4-2-stable/actionpack/CHANGELOG.md) for previous changes. diff --git a/actionpack/lib/action_pack/gem_version.rb b/actionpack/lib/action_pack/gem_version.rb index 9b3ea30f69..255ac9f4ed 100644 --- a/actionpack/lib/action_pack/gem_version.rb +++ b/actionpack/lib/action_pack/gem_version.rb @@ -5,10 +5,10 @@ module ActionPack end module VERSION - MAJOR = 4 - MINOR = 2 + MAJOR = 5 + MINOR = 0 TINY = 0 - PRE = "beta4" + PRE = "alpha" STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".") end diff --git a/actionview/CHANGELOG.md b/actionview/CHANGELOG.md index de65543137..729717608f 100644 --- a/actionview/CHANGELOG.md +++ b/actionview/CHANGELOG.md @@ -1,218 +1 @@ -* Local variable in a partial is now available even if a falsy value is - passed to `:object` when rendering a partial. - - Fixes #17373. - - *Agis Anastasopoulos* - -* Add support for `:enforce_utf8` option in `form_for`. - - This is the same option that was added in 06388b0 to `form_tag` and allows - users to skip the insertion of the UTF8 enforcer tag in a form. - - * claudiob * - -* Fix a bug that <%= foo(){ %> and <%= foo()do %> in view templates were not regarded - as Ruby block calls. - - * Akira Matsuda * - -* Update `select_tag` to work correctly with `:include_blank` option passing a string. - - Fixes #16483. - - *Frank Groeneveld* - -* Changed the meaning of `render "foo/bar"`. - - Previously, calling `render "foo/bar"` in a controller action is equivalent - to `render file: "foo/bar"`. In Rails 4.2, this has been changed to mean - `render template: "foo/bar"` instead. If you need to render a file, please - change your code to use the explicit form (`render file: "foo/bar"`) instead. - - *Jeremy Jackson* - -* Add support for ARIA attributes in tags. - - Example: - - <%= f.text_field :name, aria: { required: "true", hidden: "false" } %> - - now generates: - - <input aria-hidden="false" aria-required="true" id="user_name" name="user[name]" type="text"> - - *Paola Garcia Casadiego* - -* Provide a `builder` object when using the `label` form helper in block form. - - The new `builder` object responds to `translation`, allowing I18n fallback support - when you want to customize how a particular label is presented. - - *Alex Robbin* - -* Add I18n support for input/textarea placeholder text. - - Placeholder I18n follows the same convention as `label` I18n. - - *Alex Robbin* - -* Fix that render layout: 'messages/layout' should also be added to the dependency tracker tree. - - *DHH* - -* Add `PartialIteration` object used when rendering collections. - - The iteration object is available as the local variable - `#{template_name}_iteration` when rendering partials with collections. - - It gives access to the `size` of the collection being iterated over, - the current `index` and two convenience methods `first?` and `last?`. - - *Joel Junström*, *Lucas Uyezu* - -* Return an absolute instead of relative path from an asset url in the case - of the `asset_host` proc returning nil. - - *Jolyon Pawlyn* - -* Fix `html_escape_once` to properly handle hex escape sequences (e.g. ᨫ). - - *John F. Douthat* - -* Added String support for min and max properties for date field helpers. - - *Todd Bealmear* - -* The `highlight` helper now accepts a block to be used instead of the `highlighter` - option. - - *Lucas Mazza* - -* The `except` and `highlight` helpers now accept regular expressions. - - *Jan Szumiec* - -* Flatten the array parameter in `safe_join`, so it behaves consistently with - `Array#join`. - - *Paul Grayson* - -* Honor `html_safe` on array elements in tag values, as we do for plain string - values. - - *Paul Grayson* - -* Add `ActionView::Template::Handler.unregister_template_handler`. - - It performs the opposite of `ActionView::Template::Handler.register_template_handler`. - - *Zuhao Wan* - -* Bring `cache_digest` rake tasks up-to-date with the latest API changes. - - *Jiri Pospisil* - -* Allow custom `:host` option to be passed to `asset_url` helper that - overwrites `config.action_controller.asset_host` for particular asset. - - *Hubert Łępicki* - -* Deprecate `AbstractController::Base.parent_prefixes`. - Override `AbstractController::Base.local_prefixes` when you want to change - where to find views. - - *Nick Sutterer* - -* Take label values into account when doing I18n lookups for model attributes. - - The following: - - # form.html.erb - <%= form_for @post do |f| %> - <%= f.label :type, value: "long" %> - <% end %> - - # en.yml - en: - activerecord: - attributes: - post/long: "Long-form Post" - - Used to simply return "long", but now it will return "Long-form - Post". - - *Joshua Cody* - -* Change `asset_path` to use File.join to create proper paths: - - Before: - - https://some.host.com//assets/some.js - - After: - - https://some.host.com/assets/some.js - - *Peter Schröder* - -* Change `favicon_link_tag` default mimetype from `image/vnd.microsoft.icon` to - `image/x-icon`. - - Before: - - # => favicon_link_tag 'myicon.ico' - <link href="/assets/myicon.ico" rel="shortcut icon" type="image/vnd.microsoft.icon" /> - - After: - - # => favicon_link_tag 'myicon.ico' - <link href="/assets/myicon.ico" rel="shortcut icon" type="image/x-icon" /> - - *Geoffroy Lorieux* - -* Remove wrapping div with inline styles for hidden form fields. - - We are dropping HTML 4.01 and XHTML strict compliance since input tags directly - inside a form are valid HTML5, and the absence of inline styles help in validating - for Content Security Policy. - - *Joost Baaij* - -* `collection_check_boxes` respects `:index` option for the hidden field name. - - Fixes #14147. - - *Vasiliy Ermolovich* - -* `date_select` helper with option `with_css_classes: true` does not overwrite other classes. - - *Izumi Wong-Horiuchi* - -* `number_to_percentage` does not crash with `Float::NAN` or `Float::INFINITY` - as input. - - Fixes #14405. - - *Yves Senn* - -* Add `include_hidden` option to `collection_check_boxes` helper. - - *Vasiliy Ermolovich* - -* Fixed a problem where the default options for the `button_tag` helper are not - applied correctly. - - Fixes #14254. - - *Sergey Prikhodko* - -* Take variants into account when calculating template digests in ActionView::Digestor. - - The arguments to ActionView::Digestor#digest are now being passed as a hash - to support variants and allow more flexibility in the future. The support for - regular (required) arguments is deprecated and will be removed in Rails 5.0 or later. - - *Piotr Chmolowski, Łukasz Strzałkowski* - -Please check [4-1-stable](https://github.com/rails/rails/blob/4-1-stable/actionview/CHANGELOG.md) for previous changes. +Please check [4-2-stable](https://github.com/rails/rails/blob/4-2-stable/actionview/CHANGELOG.md) for previous changes. diff --git a/actionview/lib/action_view/gem_version.rb b/actionview/lib/action_view/gem_version.rb index 752eafee3c..4f45f5b8c8 100644 --- a/actionview/lib/action_view/gem_version.rb +++ b/actionview/lib/action_view/gem_version.rb @@ -5,10 +5,10 @@ module ActionView end module VERSION - MAJOR = 4 - MINOR = 2 + MAJOR = 5 + MINOR = 0 TINY = 0 - PRE = "beta4" + PRE = "alpha" STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".") end diff --git a/activejob/CHANGELOG.md b/activejob/CHANGELOG.md index b04883413e..f9c481998e 100644 --- a/activejob/CHANGELOG.md +++ b/activejob/CHANGELOG.md @@ -1 +1 @@ -* Started project.
\ No newline at end of file +Please check [4-2-stable](https://github.com/rails/rails/blob/4-2-stable/activejob/CHANGELOG.md) for previous changes. diff --git a/activejob/lib/active_job/gem_version.rb b/activejob/lib/active_job/gem_version.rb index ac364f77d1..27a5de93f4 100644 --- a/activejob/lib/active_job/gem_version.rb +++ b/activejob/lib/active_job/gem_version.rb @@ -5,10 +5,10 @@ module ActiveJob end module VERSION - MAJOR = 4 - MINOR = 2 + MAJOR = 5 + MINOR = 0 TINY = 0 - PRE = "beta4" + PRE = "alpha" STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".") end diff --git a/activemodel/CHANGELOG.md b/activemodel/CHANGELOG.md index 5588699d9b..b86e988841 100644 --- a/activemodel/CHANGELOG.md +++ b/activemodel/CHANGELOG.md @@ -1,61 +1 @@ -* Passwords with spaces only allowed in `ActiveModel::SecurePassword`. - - Presence validation can be used to restore old behavior. - - *Yevhene Shemet* - -* Validate options passed to `ActiveModel::Validations.validate`. - - Preventing, in many cases, the simple mistake of using `validate` instead of `validates`. - - *Sonny Michaud* - -* Deprecate `reset_#{attribute}` in favor of `restore_#{attribute}`. - - These methods may cause confusion with the `reset_changes`, which has - different behaviour. - - *Rafael Mendonça França* - -* Deprecate `ActiveModel::Dirty#reset_changes` in favor of `#clear_changes_information`. - - Method's name is causing confusion with the `reset_#{attribute}` methods. - While `reset_name` sets the value of the name attribute to previous value - `reset_changes` only discards the changes. - - *Rafael Mendonça França* - -* Added `restore_attributes` method to `ActiveModel::Dirty` API which restores - the value of changed attributes to previous value. - - *Igor G.* - -* Allow proc and symbol as values for `only_integer` of `NumericalityValidator` - - *Robin Mehner* - -* `has_secure_password` now verifies that the given password is less than 72 - characters if validations are enabled. - - Fixes #14591. - - *Akshay Vishnoi* - -* Remove deprecated `Validator#setup` without replacement. - - See #10716. - - *Kuldeep Aggarwal* - -* Add plural and singular form for length validator's default messages. - - *Abd ar-Rahman Hamid* - -* Introduce `validate` as an alias for `valid?`. - - This is more intuitive when you want to run validations but don't care about - the return value. - - *Henrik Nyh* - -Please check [4-1-stable](https://github.com/rails/rails/blob/4-1-stable/activemodel/CHANGELOG.md) for previous changes. +Please check [4-2-stable](https://github.com/rails/rails/blob/4-2-stable/activemodel/CHANGELOG.md) for previous changes. diff --git a/activemodel/lib/active_model/gem_version.rb b/activemodel/lib/active_model/gem_version.rb index 932fe3e5a9..2403242ce6 100644 --- a/activemodel/lib/active_model/gem_version.rb +++ b/activemodel/lib/active_model/gem_version.rb @@ -5,10 +5,10 @@ module ActiveModel end module VERSION - MAJOR = 4 - MINOR = 2 + MAJOR = 5 + MINOR = 0 TINY = 0 - PRE = "beta4" + PRE = "alpha" STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".") end diff --git a/activerecord/CHANGELOG.md b/activerecord/CHANGELOG.md index a6ed8cdb06..38c5583708 100644 --- a/activerecord/CHANGELOG.md +++ b/activerecord/CHANGELOG.md @@ -1,1336 +1 @@ -* Bring back `db:test:prepare` to synchronize the test database schema. - - Manual synchronization using `bin/rake db:test:prepare` is required - when a migration is rolled-back, edited and reapplied. - - `ActiveRecord::Base.maintain_test_schema` now uses `db:test:prepare` - to synchronize the schema. Plugins can use this task as a hook to - provide custom behavior after the schema has been loaded. - - NOTE: `test:prepare` runs before the schema is synchronized. - - Fixes #17171, #15787. - - *Yves Senn* - -* Change `reflections` public api to return the keys as String objects. - - Fixes #16928. - - *arthurnn* - -* Renaming a table in pg also renames the primary key index. - - Fixes #12856 - - *Sean Griffin* - -* Make it possible to access fixtures excluded by a `default_scope`. - - *Yves Senn* - -* Fix preloading of associations with a scope containing joins along with - conditions on the joined association. - - *Siddharth Sharma* - -* Add `Table#name` to match `TableDefinition#name`. - - *Cody Cutrer* - -* Cache `CollectionAssociation#reader` proxies separately before and after - the owner has been saved so that the proxy is not cached without the - owner's id. - - *Ben Woosley* - -* `ActiveRecord::ReadOnlyRecord` now has a descriptive message. - - *Franky W.* - -* Fix preloading of associations which unscope a default scope. - - Fixes #11036. - - *Byron Bischoff* - -* Added SchemaDumper support for tables with jsonb columns. - - *Ted O'Meara* - -* Deprecate `sanitize_sql_hash_for_conditions` without replacement. Using a - `Relation` for performing queries and updates is the prefered API. - - *Sean Griffin* - -* Queries now properly type cast values that are part of a join statement, - even when using type decorators such as `serialize`. - - *Melanie Gilman & Sean Griffin* - -* MySQL enum type lookups, with values matching another type, no longer result - in an endless loop. - - Fixes #17402. - - *Yves Senn* - -* Raise `ArgumentError` when the body of a scope is not callable. - - *Mauro George* - -* Use type column first in multi-column indexes created with `add-reference`. - - *Derek Prior* - -* Fix `Relation.rewhere` to work with Range values. - - *Dan Olson* - -* `AR::UnknownAttributeError` now includes the class name of a record. - - User.new(name: "Yuki Nishijima", project_attributes: {name: "kaminari"}) - # => ActiveRecord::UnknownAttributeError: unknown attribute 'name' for User. - - *Yuki Nishijima* - -* Fix a regression causing `after_create` callbacks to run before associated - records are autosaved. - - Fixes #17209. - - *Agis Anastasopoulos* - -* Honor overridden `rack.test` in Rack environment for the connection - management middleware. - - *Simon Eskildsen* - -* Add a truncate method to the connection. - - *Aaron Patterson* - -* Don't autosave unchanged has_one through records. - - *Alan Kennedy*, *Steve Parrington* - -* Do not dump foreign keys for ignored tables. - - *Yves Senn* - -* PostgreSQL adapter correctly dumps foreign keys targeting tables - outside the schema search path. - - Fixes #16907. - - *Matthew Draper*, *Yves Senn* - -* When a thread is killed, rollback the active transaction, instead of - committing it during the stack unwind. Previously, we could commit half- - completed work. This fix only works for Ruby 2.0+; on 1.9, we can't - distinguish a thread kill from an ordinary non-local (block) return, so must - default to committing. - - *Chris Hanks* - -* A `NullRelation` should represent nothing. This fixes a bug where - `Comment.where(post_id: Post.none)` returned a non-empty result. - - Fixes #15176. - - *Matthew Draper*, *Yves Senn* - -* Include default column limits in schema.rb. Allows defaults to be changed - in the future without affecting old migrations that assumed old defaults. - - *Jeremy Kemper* - -* MySQL: schema.rb now includes TEXT and BLOB column limits. - - *Jeremy Kemper* - -* MySQL: correct LONGTEXT and LONGBLOB limits from 2GB to their true 4GB. - - *Jeremy Kemper* - -* SQLite3Adapter now checks for views in `table_exists?`. Fixes #14041. - - *Girish Sonawane* - -* Introduce `connection.supports_views?` to check whether the current adapter - has support for SQL views. Connection adapters should define this method. - - *Yves Senn* - -* Allow included modules to override association methods. - - Fixes #16684. - - *Yves Senn* - -* Schema loading rake tasks (like `db:schema:load` and `db:setup`) maintain - the database connection to the current environment. - - Fixes #16757. - - *Joshua Cody*, *Yves Senn* - -* MySQL: set the connection collation along with the charset. - - Sets the connection collation to the database collation configured in - database.yml. Otherwise, `SET NAMES utf8mb4` will use the default - collation for that charset (utf8mb4_general_ci) when you may have chosen - a different collation, like utf8mb4_unicode_ci. - - This only applies to literal string comparisons, not column values, so it - is unlikely to affect you. - - *Jeremy Kemper* - -* `default_sequence_name` from the PostgreSQL adapter returns a `String`. - - *Yves Senn* - -* Fix a regression where whitespaces were stripped from DISTINCT queries in - PostgreSQL. - - *Agis Anastasopoulos* - - Fixes #16623. - -* Fix has_many :through relation merging failing when dynamic conditions are - passed as a lambda with an arity of one. - - Fixes #16128. - - *Agis Anastasopoulos* - -* Fix `Relation#exists?` to work with polymorphic associations. - - Fixes #15821. - - *Kassio Borges* - -* Currently, Active Record rescues any errors raised within - `after_rollback`/`after_create` callbacks and prints them to the logs. - Future versions of Rails will not rescue these errors anymore and - just bubble them up like the other callbacks. - - This commit adds an opt-in flag to enable not rescuing the errors. - - Example: - - # Do not swallow errors in after_commit/after_rollback callbacks. - config.active_record.raise_in_transactional_callbacks = true - - Fixes #13460. - - *arthurnn* - -* Fix an issue where custom accessor methods (such as those generated by - `enum`) with the same name as a global method are incorrectly overridden - when subclassing. - - Fixes #16288. - - *Godfrey Chan* - -* `*_was` and `changes` now work correctly for in-place attribute changes as - well. - - *Sean Griffin* - -* Fix regression on `after_commit` that did not fire with nested transactions. - - Fixes #16425. - - *arthurnn* - -* Do not try to write timestamps when a table has no timestamps columns. - - Fixes #8813. - - *Sergey Potapov* - -* `index_exists?` with `:name` option does verify specified columns. - - Example: - - add_index :articles, :title, name: "idx_title" - - # Before: - index_exists? :articles, :title, name: "idx_title" # => `true` - index_exists? :articles, :body, name: "idx_title" # => `true` - - # After: - index_exists? :articles, :title, name: "idx_title" # => `true` - index_exists? :articles, :body, name: "idx_title" # => `false` - - *Yves Senn*, *Matthew Draper* - -* When calling `update_columns` on a record that is not persisted, the error - message now reflects whether that object is a new record or has been - destroyed. - - *Lachlan Sylvester* - -* Define `id_was` to get the previous value of the primary key. - - Currently when we call `id_was` and we have a custom primary key name, - Active Record will return the current value of the primary key. This - makes it impossible to correctly do an update operation if you change the - id. - - Fixes #16413. - - *Rafael Mendonça França* - -* Deprecate `DatabaseTasks.load_schema` to act on the current connection. - Use `.load_schema_current` instead. In the future `load_schema` will - require the `configuration` to act on as an argument. - - *Yves Senn* - -* Fix automatic maintaining test schema to properly handle sql structure - schema format. - - Fixes #15394. - - *Wojciech Wnętrzak* - -* Fix type casting to Decimal from Float with large precision. - - *Tomohiro Hashidate* - -* Deprecate `Reflection#source_macro` - - `Reflection#source_macro` is no longer needed in Active Record - source so it has been deprecated. Code that used `source_macro` - was removed in #16353. - - *Eileen M. Uchtitelle*, *Aaron Patterson* - -* No verbose backtrace by `db:drop` when database does not exist. - - Fixes #16295. - - *Kenn Ejima* - -* Add support for PostgreSQL JSONB. - - Example: - - create_table :posts do |t| - t.jsonb :meta_data - end - - *Philippe Creux*, *Chris Teague* - -* `db:purge` with MySQL respects `Rails.env`. - - *Yves Senn* - -* `change_column_default :table, :column, nil` with PostgreSQL will issue a - `DROP DEFAULT` instead of a `DEFAULT NULL` query. - - Fixes #16261. - - *Matthew Draper*, *Yves Senn* - -* Allow to specify a type for the foreign key column in `references` - and `add_reference`. - - Example: - - change_table :vehicle do |t| - t.references :station, type: :uuid - end - - *Andrey Novikov*, *Łukasz Sarnacki* - -* `create_join_table` removes a common prefix when generating the join table. - This matches the existing behavior of HABTM associations. - - Fixes #13683. - - *Stefan Kanev* - -* Do not swallow errors on `compute_type` when having a bad `alias_method` on - a class. - - *arthurnn* - -* PostgreSQL invalid `uuid` are convert to nil. - - *Abdelkader Boudih* - -* Restore 4.0 behavior for using serialize attributes with `JSON` as coder. - - With 4.1.x, `serialize` started returning a string when `JSON` was passed as - the second attribute. It will now return a hash as per previous versions. - - Example: - - class Post < ActiveRecord::Base - serialize :comment, JSON - end - - class Comment - include ActiveModel::Model - attr_accessor :category, :text - end - - post = Post.create! - post.comment = Comment.new(category: "Animals", text: "This is a comment about squirrels.") - post.save! - - # 4.0 - post.comment # => {"category"=>"Animals", "text"=>"This is a comment about squirrels."} - - # 4.1 before - post.comment # => "#<Comment:0x007f80ab48ff98>" - - # 4.1 after - post.comment # => {"category"=>"Animals", "text"=>"This is a comment about squirrels."} - - When using `JSON` as the coder in `serialize`, Active Record will use the - new `ActiveRecord::Coders::JSON` coder which delegates its `dump/load` to - `ActiveSupport::JSON.encode/decode`. This ensures special objects are dumped - correctly using the `#as_json` hook. - - To keep the previous behaviour, supply a custom coder instead - ([example](https://gist.github.com/jenncoop/8c4142bbe59da77daa63)). - - Fixes #15594. - - *Jenn Cooper* - -* Do not use `RENAME INDEX` syntax for MariaDB 10.0. - - Fixes #15931. - - *Jeff Browning* - -* Calling `#empty?` on a `has_many` association would use the value from the - counter cache if one exists. - - *David Verhasselt* - -* Fix the schema dump generated for tables without constraints and with - primary key with default value of custom PostgreSQL function result. - - Fixes #16111. - - *Andrey Novikov* - -* Fix the SQL generated when a `delete_all` is run on an association to not - produce an `IN` statements. - - Before: - - UPDATE "categorizations" SET "category_id" = NULL WHERE - "categorizations"."category_id" = 1 AND "categorizations"."id" IN (1, 2) - - After: - - UPDATE "categorizations" SET "category_id" = NULL WHERE - "categorizations"."category_id" = 1 - - *Eileen M. Uchitelle, Aaron Patterson* - -* Avoid type casting boolean and `ActiveSupport::Duration` values to numeric - values for string columns. Otherwise, in some database, the string column - values will be coerced to a numeric allowing false or 0.seconds match any - string starting with a non-digit. - - Example: - - App.where(apikey: false) # => SELECT * FROM users WHERE apikey = '0' - - *Dylan Thacker-Smith* - -* Add a `:required` option to singular associations, providing a nicer - API for presence validations on associations. - - *Sean Griffin* - -* Fix an error in `reset_counters` when associations have `select` scope. - (Call to `count` generated invalid SQL.) - - *Cade Truitt* - -* After a successful `reload`, `new_record?` is always false. - - Fixes #12101. - - *Matthew Draper* - -* PostgreSQL renaming table doesn't attempt to rename non existent sequences. - - *Abdelkader Boudih* - -* Move 'dependent: :destroy' handling for `belongs_to` - from `before_destroy` to `after_destroy` callback chain - - Fixes #12380. - - *Ivan Antropov* - -* Detect in-place modifications on String attributes. - - Before this change, an attribute modified in-place had to be marked as - changed in order for it to be persisted in the database. Now it is no longer - required. - - Before: - - user = User.first - user.name << ' Griffin' - user.name_will_change! - user.save - user.reload.name # => "Sean Griffin" - - After: - - user = User.first - user.name << ' Griffin' - user.save - user.reload.name # => "Sean Griffin" - - *Sean Griffin* - -* Add `ActiveRecord::Base#validate!` that raises `RecordInvalid` if the record - is invalid. - - *Bogdan Gusiev*, *Marc Schütz* - -* Support for adding and removing foreign keys. Foreign keys are now - a part of `schema.rb`. This is supported by Mysql2Adapter, MysqlAdapter - and PostgreSQLAdapter. - - Many thanks to *Matthew Higgins* for laying the foundation with his work on - [foreigner](https://github.com/matthuhiggins/foreigner). - - Example: - - # within your migrations: - add_foreign_key :articles, :authors - remove_foreign_key :articles, :authors - - *Yves Senn* - -* Fix subtle bugs regarding attribute assignment on models with no primary - key. `'id'` will no longer be part of the attributes hash. - - *Sean Griffin* - -* Deprecate automatic counter caches on `has_many :through`. The behavior was - broken and inconsistent. - - *Sean Griffin* - -* `preload` preserves readonly flag for associations. - - See #15853. - - *Yves Senn* - -* Assume numeric types have changed if they were assigned to a value that - would fail numericality validation, regardless of the old value. Previously - this would only occur if the old value was 0. - - Example: - - model = Model.create!(number: 5) - model.number = '5wibble' - model.number_changed? # => true - - Fixes #14731. - - *Sean Griffin* - -* `reload` no longer merges with the existing attributes. - The attribute hash is fully replaced. The record is put into the same state - as it would be with `Model.find(model.id)`. - - *Sean Griffin* - -* The object returned from `select_all` must respond to `column_types`. - If this is not the case a `NoMethodError` is raised. - - *Sean Griffin* - -* Detect in-place modifications of PG array types - - *Sean Griffin* - -* Add `bin/rake db:purge` task to empty the current database. - - *Yves Senn* - -* Deprecate `serialized_attributes` without replacement. - - *Sean Griffin* - -* Correctly extract IPv6 addresses from `DATABASE_URI`: the square brackets - are part of the URI structure, not the actual host. - - Fixes #15705. - - *Andy Bakun*, *Aaron Stone* - -* Ensure both parent IDs are set on join records when both sides of a - through association are new. - - *Sean Griffin* - -* `ActiveRecord::Dirty` now detects in-place changes to mutable values. - Serialized attributes on ActiveRecord models will no longer save when - unchanged. - - Fixes #8328. - - *Sean Griffin* - -* `Pluck` now works when selecting columns from different tables with the same - name. - - Fixes #15649. - - *Sean Griffin* - -* Remove `cache_attributes` and friends. All attributes are cached. - - *Sean Griffin* - -* Remove deprecated method `ActiveRecord::Base.quoted_locking_column`. - - *Akshay Vishnoi* - -* `ActiveRecord::FinderMethods.find` with block can handle proc parameter as - `Enumerable#find` does. - - Fixes #15382. - - *James Yang* - -* Make timezone aware attributes work with PostgreSQL array columns. - - Fixes #13402. - - *Kuldeep Aggarwal*, *Sean Griffin* - -* `ActiveRecord::SchemaMigration` has no primary key regardless of the - `primary_key_prefix_type` configuration. - - Fixes #15051. - - *JoseLuis Torres*, *Yves Senn* - -* `rake db:migrate:status` works with legacy migration numbers like `00018_xyz.rb`. - - Fixes #15538. - - *Yves Senn* - -* Baseclass becomes! subclass. - - Before this change, a record which changed its STI type, could not be - updated. - - Fixes #14785. - - *Matthew Draper*, *Earl St Sauver*, *Edo Balvers* - -* Remove deprecated `ActiveRecord::Migrator.proper_table_name`. Use the - `proper_table_name` instance method on `ActiveRecord::Migration` instead. - - *Akshay Vishnoi* - -* Fix regression on eager loading association based on SQL query rather than - existing column. - - Fixes #15480. - - *Lauro Caetano*, *Carlos Antonio da Silva* - -* Deprecate returning `nil` from `column_for_attribute` when no column exists. - It will return a null object in Rails 5.0 - - *Sean Griffin* - -* Implemented `ActiveRecord::Base#pretty_print` to work with PP. - - *Ethan* - -* Preserve type when dumping PostgreSQL point, bit, bit varying and money - columns. - - *Yves Senn* - -* New records remain new after YAML serialization. - - *Sean Griffin* - -* PostgreSQL support default values for enum types. Fixes #7814. - - *Yves Senn* - -* PostgreSQL `default_sequence_name` respects schema. Fixes #7516. - - *Yves Senn* - -* Fix `columns_for_distinct` of PostgreSQL adapter to work correctly - with orders without sort direction modifiers. - - *Nikolay Kondratyev* - -* PostgreSQL `reset_pk_sequence!` respects schemas. Fixes #14719. - - *Yves Senn* - -* Keep PostgreSQL `hstore` and `json` attributes as `Hash` in `@attributes`. - Fixes duplication in combination with `store_accessor`. - - Fixes #15369. - - *Yves Senn* - -* `rake railties:install:migrations` respects the order of railties. - - *Arun Agrawal* - -* Fix redefine a `has_and_belongs_to_many` inside inherited class - Fixing regression case, where redefining the same `has_and_belongs_to_many` - definition into a subclass would raise. - - Fixes #14983. - - *arthurnn* - -* Fix `has_and_belongs_to_many` public reflection. - When defining a `has_and_belongs_to_many`, internally we convert that to two has_many. - But as `reflections` is a public API, people expect to see the right macro. - - Fixes #14682. - - *arthurnn* - -* Fix serialization for records with an attribute named `format`. - - Fixes #15188. - - *Godfrey Chan* - -* When a `group` is set, `sum`, `size`, `average`, `minimum` and `maximum` - on a NullRelation should return a Hash. - - *Kuldeep Aggarwal* - -* Fix serialized fields returning serialized data after being updated with - `update_column`. - - *Simon Hørup Eskildsen* - -* Fix polymorphic eager loading when using a String as foreign key. - - Fixes #14734. - - *Lauro Caetano* - -* Change belongs_to touch to be consistent with timestamp updates - - If a model is set up with a belongs_to: touch relationship the parent - record will only be touched if the record was modified. This makes it - consistent with timestamp updating on the record itself. - - *Brock Trappitt* - -* Fix the inferred table name of a `has_and_belongs_to_many` auxiliary - table inside a schema. - - Fixes #14824. - - *Eric Chahin* - -* Remove unused `:timestamp` type. Transparently alias it to `:datetime` - in all cases. Fixes inconsistencies when column types are sent outside of - `ActiveRecord`, such as for XML Serialization. - - *Sean Griffin* - -* Fix bug that added `table_name_prefix` and `table_name_suffix` to - extension names in PostgreSQL when migrating. - - *Joao Carlos* - -* The `:index` option in migrations, which previously was only available for - `references`, now works with any column types. - - *Marc Schütz* - -* Add support for counter name to be passed as parameter on `CounterCache::ClassMethods#reset_counters`. - - *jnormore* - -* Restrict deletion of record when using `delete_all` with `uniq`, `group`, `having` - or `offset`. - - In these cases the generated query ignored them and that caused unintended - records to be deleted. - - Fixes #11985. - - *Leandro Facchinetti* - -* Floats with limit >= 25 that get turned into doubles in MySQL no longer have - their limit dropped from the schema. - - Fixes #14135. - - *Aaron Nelson* - -* Fix how to calculate associated class name when using namespaced `has_and_belongs_to_many` - association. - - Fixes #14709. - - *Kassio Borges* - -* `ActiveRecord::Relation::Merger#filter_binds` now compares equivalent symbols and - strings in column names as equal. - - This fixes a rare case in which more bind values are passed than there are - placeholders for them in the generated SQL statement, which can make PostgreSQL - throw a `StatementInvalid` exception. - - *Nat Budin* - -* Fix `stored_attributes` to correctly merge the details of stored - attributes defined in parent classes. - - Fixes #14672. - - *Brad Bennett*, *Jessica Yao*, *Lakshmi Parthasarathy* - -* `change_column_default` allows `[]` as argument to `change_column_default`. - - Fixes #11586. - - *Yves Senn* - -* Handle `name` and `"char"` column types in the PostgreSQL adapter. - - `name` and `"char"` are special character types used internally by - PostgreSQL and are used by internal system catalogs. These field types - can sometimes show up in structure-sniffing queries that feature internal system - structures or with certain PostgreSQL extensions. - - *J Smith*, *Yves Senn* - -* Fix `PostgreSQLAdapter::OID::Float#type_cast` to convert Infinity and - NaN PostgreSQL values into a native Ruby `Float::INFINITY` and `Float::NAN` - - Before: - - Point.create(value: 1.0/0) - Point.last.value # => 0.0 - - After: - - Point.create(value: 1.0/0) - Point.last.value # => Infinity - - *Innokenty Mikhailov* - -* Allow the PostgreSQL adapter to handle bigserial primary key types again. - - Fixes #10410. - - *Patrick Robertson* - -* Deprecate joining, eager loading and preloading of instance dependent - associations without replacement. These operations happen before instances - are created. The current behavior is unexpected and can result in broken - behavior. - - Fixes #15024. - - *Yves Senn* - -* Fix `has_and_belongs_to_many` CollectionAssociation size calculations. - - `has_and_belongs_to_many` should fall back to using the normal CollectionAssociation's - size calculation if the collection is not cached or loaded. - - Fixes #14913, #14914. - - *Fred Wu* - -* Return a non zero status when running `rake db:migrate:status` and migration table does - not exist. - - *Paul B.* - -* Add support for module-level `table_name_suffix` in models. - - This makes `table_name_suffix` work the same way as `table_name_prefix` when - using namespaced models. - - *Jenner LaFave* - -* Revert the behaviour of `ActiveRecord::Relation#join` changed through 4.0 => 4.1 to 4.0. - - In 4.1.0 `Relation#join` is delegated to `Arel#SelectManager`. - In 4.0 series it is delegated to `Array#join`. - - *Bogdan Gusiev* - -* Log nil binary column values correctly. - - When an object with a binary column is updated with a nil value - in that column, the SQL logger would throw an exception when trying - to log that nil value. This only occurs when updating a record - that already has a non-nil value in that column since an initial nil - value isn't included in the SQL anyway (at least, when dirty checking - is enabled.) The column's new value will now be logged as `<NULL binary data>` - to parallel the existing `<N bytes of binary data>` for non-nil values. - - *James Coleman* - -* Rails will now pass a custom validation context through to autosave associations - in order to validate child associations with the same context. - - Fixes #13854. - - *Eric Chahin*, *Aaron Nelson*, *Kevin Casey* - -* Stringify all variables keys of MySQL connection configuration. - - When `sql_mode` variable for MySQL adapters set in configuration as `String` - was ignored and overwritten by strict mode option. - - Fixes #14895. - - *Paul Nikitochkin* - -* Ensure SQLite3 statements are closed on errors. - - Fixes #13631. - - *Timur Alperovich* - -* Give `ActiveRecord::PredicateBuilder` private methods the privacy they deserve. - - *Hector Satre* - -* When using a custom `join_table` name on a `habtm`, rails was not saving it - on Reflections. This causes a problem when rails loads fixtures, because it - uses the reflections to set database with fixtures. - - Fixes #14845. - - *Kassio Borges* - -* Reset the cache when modifying a Relation with cached Arel. - Additionally display a warning message to make the user aware. - - *Yves Senn* - -* PostgreSQL should internally use `:datetime` consistently for TimeStamp. Assures - different spellings of timestamps are treated the same. - - Example: - - mytimestamp.simplified_type('timestamp without time zone') - # => :datetime - mytimestamp.simplified_type('timestamp(6) without time zone') - # => also :datetime (previously would be :timestamp) - - See #14513. - - *Jefferson Lai* - -* `ActiveRecord::Base.no_touching` no longer triggers callbacks or start empty transactions. - - Fixes #14841. - - *Lucas Mazza* - -* Fix name collision with `Array#select!` with `Relation#select!`. - - Fixes #14752. - - *Earl St Sauver* - -* Fix unexpected behavior for `has_many :through` associations going through - a scoped `has_many`. - - If a `has_many` association is adjusted using a scope, and another - `has_many :through` uses this association, then the scope adjustment is - unexpectedly neglected. - - Fixes #14537. - - *Jan Habermann* - -* `@destroyed` should always be set to `false` when an object is duped. - - *Kuldeep Aggarwal* - -* Enable `has_many` associations to support irregular inflections. - - Fixes #8928. - - *arthurnn*, *Javier Goizueta* - -* Fix `count` used with a grouping not returning a Hash. - - Fixes #14721. - - *Eric Chahin* - -* `sanitize_sql_like` helper method to escape a string for safe use in an SQL - LIKE statement. - - Example: - - class Article - def self.search(term) - where("title LIKE ?", sanitize_sql_like(term)) - end - end - - Article.search("20% _reduction_") - # => Query looks like "... title LIKE '20\% \_reduction\_' ..." - - *Rob Gilson*, *Yves Senn* - -* Do not quote uuid default value on `change_column`. - - Fixes #14604. - - *Eric Chahin* - -* The comparison between `Relation` and `CollectionProxy` should be consistent. - - Example: - - author.posts == Post.where(author_id: author.id) - # => true - Post.where(author_id: author.id) == author.posts - # => true - - Fixes #13506. - - *Lauro Caetano* - -* Calling `delete_all` on an unloaded `CollectionProxy` no longer - generates an SQL statement containing each id of the collection: - - Before: - - DELETE FROM `model` WHERE `model`.`parent_id` = 1 - AND `model`.`id` IN (1, 2, 3...) - - After: - - DELETE FROM `model` WHERE `model`.`parent_id` = 1 - - *Eileen M. Uchitelle*, *Aaron Patterson* - -* Fix invalid SQL when aggregate methods (`empty?`, `any?`, `count`) used - with `select`. - - Fixes #13648. - - *Simon Woker* - -* PostgreSQL adapter only warns once for every missing OID per connection. - - Fixes #14275. - - *Matthew Draper*, *Yves Senn* - -* PostgreSQL adapter automatically reloads it's type map when encountering - unknown OIDs. - - Fixes #14678. - - *Matthew Draper*, *Yves Senn* - -* Fix insertion of records via `has_many :through` association with scope. - - Fixes #3548. - - *Ivan Antropov* - -* Auto-generate stable fixture UUIDs on PostgreSQL. - - Fixes #11524. - - *Roderick van Domburg* - -* Fix a problem where an enum would overwrite values of another enum with the - same name in an unrelated class. - - Fixes #14607. - - *Evan Whalen* - -* PostgreSQL and SQLite string columns no longer have a default limit of 255. - - Fixes #13435, #9153. - - *Vladimir Sazhin*, *Toms Mikoss*, *Yves Senn* - -* Make possible to have an association called `records`. - - Fixes #11645. - - *prathamesh-sonpatki* - -* `to_sql` on an association now matches the query that is actually executed, where it - could previously have incorrectly accrued additional conditions (e.g. as a result of - a previous query). `CollectionProxy` now always defers to the association scope's - `arel` method so the (incorrect) inherited one should be entirely concealed. - - Fixes #14003. - - *Jefferson Lai* - -* Block a few default Class methods as scope name. - - For instance, this will raise: - - scope :public, -> { where(status: 1) } - - *arthurnn* - -* Fix error when using `with_options` with lambda. - - Fixes #9805. - - *Lauro Caetano* - -* Switch `sqlite3:///` URLs (which were temporarily - deprecated in 4.1) from relative to absolute. - - If you still want the previous interpretation, you should replace - `sqlite3:///my/path` with `sqlite3:my/path`. - - *Matthew Draper* - -* Treat blank UUID values as `nil`. - - Example: - - Sample.new(uuid_field: '') #=> <Sample id: nil, uuid_field: nil> - - *Dmitry Lavrov* - -* Enable support for materialized views on PostgreSQL >= 9.3. - - *Dave Lee* - -* The PostgreSQL adapter supports custom domains. Fixes #14305. - - *Yves Senn* - -* PostgreSQL `Column#type` is now determined through the corresponding OID. - The column types stay the same except for enum columns. They no longer have - `nil` as type but `enum`. - - See #7814. - - *Yves Senn* - -* Fix error when specifying a non-empty default value on a PostgreSQL array - column. - - Fixes #10613. - - *Luke Steensen* - -* Fix error where `.persisted?` throws SystemStackError for an unsaved model with a - custom primary key that did not save due to validation error. - - Fixes #14393. - - *Chris Finne* - -* Introduce `validate` as an alias for `valid?`. - - This is more intuitive when you want to run validations but don't care about the return value. - - *Henrik Nyh* - -* Create indexes inline in CREATE TABLE for MySQL. - - This is important, because adding an index on a temporary table after it has been created - would commit the transaction. - - It also allows creating and dropping indexed tables with fewer queries and fewer permissions - required. - - Example: - - create_table :temp, temporary: true, as: "SELECT id, name, zip FROM a_really_complicated_query" do |t| - t.index :zip - end - # => CREATE TEMPORARY TABLE temp (INDEX (zip)) AS SELECT id, name, zip FROM a_really_complicated_query - - *Cody Cutrer*, *Steve Rice*, *Rafael Mendonça Franca* - -* Use singular table name in generated migrations when - `ActiveRecord::Base.pluralize_table_names` is `false`. - - Fixes #13426. - - *Kuldeep Aggarwal* - -* `touch` accepts many attributes to be touched at once. - - Example: - - # touches :signed_at, :sealed_at, and :updated_at/on attributes. - Photo.last.touch(:signed_at, :sealed_at) - - *James Pinto* - -* `rake db:structure:dump` only dumps schema information if the schema - migration table exists. - - Fixes #14217. - - *Yves Senn* - -* Reap connections that were checked out by now-dead threads, instead - of waiting until they disconnect by themselves. Before this change, - a suitably constructed series of short-lived threads could starve - the connection pool, without ever having more than a couple alive at - the same time. - - *Matthew Draper* - -* `pk_and_sequence_for` now ensures that only the pg_depend entries - pointing to pg_class, and thus only sequence objects, are considered. - - *Josh Williams* - -* `where.not` adds `references` for `includes` like normal `where` calls do. - - Fixes #14406. - - *Yves Senn* - -* Extend fixture `$LABEL` replacement to allow string interpolation. - - Example: - - martin: - email: $LABEL@email.com - - users(:martin).email # => martin@email.com - - *Eric Steele* - -* Add support for `Relation` be passed as parameter on `QueryCache#select_all`. - - Fixes #14361. - - *arthurnn* - -* Passing an Active Record object to `find` or `exists?` is now deprecated. - Call `.id` on the object first. - - *Aaron Patterson* - -* Only use BINARY for MySQL case sensitive uniqueness check when column - has a case insensitive collation. - - *Ryuta Kamizono* - -* Support for MySQL 5.6 fractional seconds. - - *arthurnn*, *Tatsuhiko Miyagawa* - -* Support for PostgreSQL `citext` data type enabling case-insensitive - `where` values without needing to wrap in UPPER/LOWER sql functions. - - *Troy Kruthoff*, *Lachlan Sylvester* - -* Only save has_one associations if record has changes. - Previously after save related callbacks, such as `#after_commit`, were triggered when the has_one - object did not get saved to the db. - - *Alan Kennedy* - -* Allow strings to specify the `#order` value. - - Example: - - Model.order(id: 'asc').to_sql == Model.order(id: :asc).to_sql - - *Marcelo Casiraghi*, *Robin Dupret* - -* Dynamically register PostgreSQL enum OIDs. This prevents "unknown OID" - warnings on enum columns. - - *Dieter Komendera* - -* `includes` is able to detect the right preloading strategy when string - joins are involved. - - Fixes #14109. - - *Aaron Patterson*, *Yves Senn* - -* Fix error with validation with enum fields for records where the value for - any enum attribute is always evaluated as 0 during uniqueness validation. - - Fixes #14172. - - *Vilius Luneckas* *Ahmed AbouElhamayed* - -* `before_add` callbacks are fired before the record is saved on - `has_and_belongs_to_many` associations *and* on `has_many :through` - associations. Before this change, `before_add` callbacks would be fired - before the record was saved on `has_and_belongs_to_many` associations, but - *not* on `has_many :through` associations. - - Fixes #14144. - -* Fix STI classes not defining an attribute method if there is a conflicting - private method defined on its ancestors. - - Fixes #11569. - - *Godfrey Chan* - -* Coerce strings when reading attributes. Fixes #10485. - - Example: - - book = Book.new(title: 12345) - book.save! - book.title # => "12345" - - *Yves Senn* - -* Deprecate half-baked support for PostgreSQL range values with excluding beginnings. - We currently map PostgreSQL ranges to Ruby ranges. This conversion is not fully - possible because the Ruby range does not support excluded beginnings. - - The current solution of incrementing the beginning is not correct and is now - deprecated. For subtypes where we don't know how to increment (e.g. `#succ` - is not defined) it will raise an `ArgumentException` for ranges with excluding - beginnings. - - *Yves Senn* - -* Support for user created range types in PostgreSQL. - - *Yves Senn* - -Please check [4-1-stable](https://github.com/rails/rails/blob/4-1-stable/activerecord/CHANGELOG.md) for previous changes. +Please check [4-2-stable](https://github.com/rails/rails/blob/4-2-stable/activerecord/CHANGELOG.md) for previous changes. diff --git a/activerecord/lib/active_record/associations/preloader.rb b/activerecord/lib/active_record/associations/preloader.rb index 46bccbf15a..4358f3b581 100644 --- a/activerecord/lib/active_record/associations/preloader.rb +++ b/activerecord/lib/active_record/associations/preloader.rb @@ -178,6 +178,7 @@ module ActiveRecord class NullPreloader def self.new(klass, owners, reflection, preload_scope); self; end def self.run(preloader); end + def self.preloaded_records; []; end end def preloader_for(reflection, owners, rhs_klass) diff --git a/activerecord/lib/active_record/connection_adapters/abstract/schema_creation.rb b/activerecord/lib/active_record/connection_adapters/abstract/schema_creation.rb index 6a684a33f8..5c95b95184 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/schema_creation.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/schema_creation.rb @@ -15,9 +15,7 @@ module ActiveRecord end def visit_AddColumn(o) - sql_type = type_to_sql(o.type, o.limit, o.precision, o.scale) - sql = "ADD #{quote_column_name(o.name)} #{sql_type}" - add_column_options!(sql, column_options(o)) + "ADD #{accept(o)}" end private diff --git a/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb b/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb index 009b7cd682..f29b793a3f 100644 --- a/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb +++ b/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb @@ -4,12 +4,6 @@ module ActiveRecord class SchemaCreation < AbstractAdapter::SchemaCreation private - def visit_AddColumn(o) - sql_type = type_to_sql(o.type, o.limit, o.precision, o.scale) - sql = "ADD COLUMN #{quote_column_name(o.name)} #{sql_type}" - add_column_options!(sql, column_options(o)) - end - def visit_ColumnDefinition(o) sql = super if o.primary_key? && o.type != :primary_key diff --git a/activerecord/lib/active_record/errors.rb b/activerecord/lib/active_record/errors.rb index 14819aab54..fc28ab585f 100644 --- a/activerecord/lib/active_record/errors.rb +++ b/activerecord/lib/active_record/errors.rb @@ -54,9 +54,9 @@ module ActiveRecord class RecordNotSaved < ActiveRecordError attr_reader :record - def initialize(record) + def initialize(message, record = nil) @record = record - super() + super(message) end end diff --git a/activerecord/lib/active_record/gem_version.rb b/activerecord/lib/active_record/gem_version.rb index e820835626..a388b529c9 100644 --- a/activerecord/lib/active_record/gem_version.rb +++ b/activerecord/lib/active_record/gem_version.rb @@ -5,10 +5,10 @@ module ActiveRecord end module VERSION - MAJOR = 4 - MINOR = 2 + MAJOR = 5 + MINOR = 0 TINY = 0 - PRE = "beta4" + PRE = "alpha" STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".") end diff --git a/activerecord/lib/active_record/persistence.rb b/activerecord/lib/active_record/persistence.rb index 8d84a3acae..99e104598b 100644 --- a/activerecord/lib/active_record/persistence.rb +++ b/activerecord/lib/active_record/persistence.rb @@ -139,7 +139,7 @@ module ActiveRecord # Attributes marked as readonly are silently ignored if the record is # being updated. def save!(*) - create_or_update || raise(RecordNotSaved, self) + create_or_update || raise(RecordNotSaved.new(nil, self)) end # Deletes the record in the database and freezes this instance to diff --git a/activerecord/test/cases/associations/eager_test.rb b/activerecord/test/cases/associations/eager_test.rb index dd4f530791..f968a34886 100644 --- a/activerecord/test/cases/associations/eager_test.rb +++ b/activerecord/test/cases/associations/eager_test.rb @@ -270,6 +270,14 @@ class EagerAssociationTest < ActiveRecord::TestCase end end + def test_three_level_nested_preloading_does_not_raise_exception_when_association_does_not_exist + post_id = Comment.where(author_id: nil).where.not(post_id: nil).first.post_id + + assert_nothing_raised do + Post.preload(:comments => [{:author => :essays}]).find(post_id) + end + end + def test_nested_loading_through_has_one_association aa = AuthorAddress.all.merge!(:includes => {:author => :posts}).find(author_addresses(:david_address).id) assert_equal aa.author.posts.count, aa.author.posts.length diff --git a/activerecord/test/cases/associations/has_many_associations_test.rb b/activerecord/test/cases/associations/has_many_associations_test.rb index 8b7ab11570..9510d57de6 100644 --- a/activerecord/test/cases/associations/has_many_associations_test.rb +++ b/activerecord/test/cases/associations/has_many_associations_test.rb @@ -589,17 +589,21 @@ class HasManyAssociationsTest < ActiveRecord::TestCase end def test_create_with_bang_on_has_many_when_parent_is_new_raises - assert_raise(ActiveRecord::RecordNotSaved) do + error = assert_raise(ActiveRecord::RecordNotSaved) do firm = Firm.new firm.plain_clients.create! :name=>"Whoever" end + + assert_equal "You cannot call create unless the parent is saved", error.message end def test_regular_create_on_has_many_when_parent_is_new_raises - assert_raise(ActiveRecord::RecordNotSaved) do + error = assert_raise(ActiveRecord::RecordNotSaved) do firm = Firm.new firm.plain_clients.create :name=>"Whoever" end + + assert_equal "You cannot call create unless the parent is saved", error.message end def test_create_with_bang_on_has_many_raises_when_record_not_saved @@ -610,9 +614,11 @@ class HasManyAssociationsTest < ActiveRecord::TestCase end def test_create_with_bang_on_habtm_when_parent_is_new_raises - assert_raise(ActiveRecord::RecordNotSaved) do + error = assert_raise(ActiveRecord::RecordNotSaved) do Developer.new("name" => "Aredridel").projects.create! end + + assert_equal "You cannot call create unless the parent is saved", error.message end def test_adding_a_mismatch_class @@ -1353,10 +1359,13 @@ class HasManyAssociationsTest < ActiveRecord::TestCase assert !account.valid? assert !orig_accounts.empty? - assert_raise ActiveRecord::RecordNotSaved do + error = assert_raise ActiveRecord::RecordNotSaved do firm.accounts = [account] end + assert_equal orig_accounts, firm.accounts + assert_equal "Failed to replace accounts because one or more of the " \ + "new records could not be saved.", error.message end def test_replace_with_same_content diff --git a/activerecord/test/cases/associations/has_many_through_associations_test.rb b/activerecord/test/cases/associations/has_many_through_associations_test.rb index df4a30ae9b..d523ea4f07 100644 --- a/activerecord/test/cases/associations/has_many_through_associations_test.rb +++ b/activerecord/test/cases/associations/has_many_through_associations_test.rb @@ -615,8 +615,11 @@ class HasManyThroughAssociationsTest < ActiveRecord::TestCase def test_create_on_new_record p = Post.new - assert_raises(ActiveRecord::RecordNotSaved) { p.people.create(:first_name => "mew") } - assert_raises(ActiveRecord::RecordNotSaved) { p.people.create!(:first_name => "snow") } + error = assert_raises(ActiveRecord::RecordNotSaved) { p.people.create(:first_name => "mew") } + assert_equal "You cannot call create unless the parent is saved", error.message + + error = assert_raises(ActiveRecord::RecordNotSaved) { p.people.create!(:first_name => "snow") } + assert_equal "You cannot call create unless the parent is saved", error.message end def test_associate_with_create_and_invalid_options diff --git a/activerecord/test/cases/associations/has_one_associations_test.rb b/activerecord/test/cases/associations/has_one_associations_test.rb index 2ecfcb521d..1a6d25f7d0 100644 --- a/activerecord/test/cases/associations/has_one_associations_test.rb +++ b/activerecord/test/cases/associations/has_one_associations_test.rb @@ -410,9 +410,11 @@ class HasOneAssociationsTest < ActiveRecord::TestCase pirate = pirates(:redbeard) new_ship = Ship.new - assert_raise(ActiveRecord::RecordNotSaved) do + error = assert_raise(ActiveRecord::RecordNotSaved) do pirate.ship = new_ship end + + assert_equal "Failed to save the new associated ship.", error.message assert_nil pirate.ship assert_nil new_ship.pirate_id end @@ -422,20 +424,25 @@ class HasOneAssociationsTest < ActiveRecord::TestCase pirate.ship.name = nil assert !pirate.ship.valid? - assert_raise(ActiveRecord::RecordNotSaved) do + error = assert_raise(ActiveRecord::RecordNotSaved) do pirate.ship = ships(:interceptor) end + assert_equal ships(:black_pearl), pirate.ship assert_equal pirate.id, pirate.ship.pirate_id + assert_equal "Failed to remove the existing associated ship. " + + "The record failed to save after its foreign key was set to nil.", error.message end def test_replacement_failure_due_to_new_record_should_raise_error pirate = pirates(:blackbeard) new_ship = Ship.new - assert_raise(ActiveRecord::RecordNotSaved) do + error = assert_raise(ActiveRecord::RecordNotSaved) do pirate.ship = new_ship end + + assert_equal "Failed to save the new associated ship.", error.message assert_equal ships(:black_pearl), pirate.ship assert_equal pirate.id, pirate.ship.pirate_id assert_equal pirate.id, ships(:black_pearl).reload.pirate_id diff --git a/activesupport/CHANGELOG.md b/activesupport/CHANGELOG.md index ed30c7de70..810fc22cf5 100644 --- a/activesupport/CHANGELOG.md +++ b/activesupport/CHANGELOG.md @@ -1,388 +1 @@ -* The decorated `load` and `require` methods are now kept private. - - Fixes #17553. - - *Xavier Noria* - -* `String#remove` and `String#remove!` accept multiple arguments. - - *Pavel Pravosud* - -* `TimeWithZone#strftime` now delegates every directive to `Time#strftime` except for '%Z', - it also now correctly handles escaped '%' characters placed just before time zone related directives. - - *Pablo Herrero* - -* Corrected `Inflector#underscore` handling of multiple successive acroynms. - - *James Le Cuirot* - -* Delegation now works with ruby reserved words passed to `:to` option. - - Fixes #16956. - - *Agis Anastasopoulos* - -* Added method `#eql?` to `ActiveSupport::Duration`, in addition to `#==`. - - Currently, the following returns `false`, contrary to expectation: - - 1.minute.eql?(1.minute) - - Adding method `#eql?` will make this behave like expected. Method `#eql?` is - just a bit stricter than `#==`, as it checks whether the argument is also a duration. Their - parts may be different though. - - 1.minute.eql?(60.seconds) # => true - 1.minute.eql?(60) # => false - - *Joost Lubach* - -* `Time#change` can now change nanoseconds (`:nsec`) as a higher-precision - alternative to microseconds (`:usec`). - - *Agis Anastasooulos* - -* `MessageVerifier.new` raises an appropriate exception if the secret is `nil`. - This prevents `MessageVerifier#generate` from raising a cryptic error later on. - - *Kostiantyn Kahanskyi* - -* Introduced new configuration option `active_support.test_order` for - specifying the order in which test cases are executed. This option currently defaults - to `:sorted` but will be changed to `:random` in Rails 5.0. - - *Akira Matsuda*, *Godfrey Chan* - -* Fixed a bug in `Inflector#underscore` where acroynms in nested constant names - are incorrectly parsed as camelCase. - - Fixes #8015. - - *Fred Wu*, *Matthew Draper* - -* Make `Time#change` throw an exception if the `:usec` option is out of range and - the time has an offset other than UTC or local. - - *Agis Anastasopoulos* - -* `Method` objects now report themselves as not `duplicable?`. This allows - hashes and arrays containing `Method` objects to be `deep_dup`ed. - - *Peter Jaros* - -* `determine_constant_from_test_name` does no longer shadow `NameError`s - which happens during constant autoloading. - - Fixes #9933. - - *Guo Xiang Tan* - -* Added instance_eval version to Object#try and Object#try!, so you can do this: - - person.try { name.first } - - instead of: - - person.try { |person| person.name.first } - - *DHH*, *Ari Pollak* - -* Fix the `ActiveSupport::Duration#instance_of?` method to return the right - value with the class itself since it was previously delegated to the - internal value. - - *Robin Dupret* - -* Fix rounding errors with `#travel_to` by resetting the usec on any passed time to zero, so we only travel - with per-second precision, not anything deeper than that. - - *DHH* - -* Fix DateTime comparison with `DateTime::Infinity` object. - - *Rafael Mendonça França* - -* Added Object#itself which returns the object itself. Useful when dealing with a chaining scenario, like Active Record scopes: - - Event.public_send(state.presence_in([ :trashed, :drafted ]) || :itself).order(:created_at) - - *DHH* - -* `Object#with_options` executes block in merging option context when - explicit receiver in not passed. - - *Pavel Pravosud* - -* Fixed a compatibility issue with the `Oj` gem when cherry-picking the file - `active_support/core_ext/object/json` without requiring `active_support/json`. - - Fixes #16131. - - *Godfrey Chan* - -* Make `Hash#with_indifferent_access` copy the default proc too. - - *arthurnn*, *Xanders* - -* Add `String#truncate_words` to truncate a string by a number of words. - - *Mohamed Osama* - -* Deprecate `capture` and `quietly`. - - These methods are not thread safe and may cause issues when used in threaded environments. - To avoid problems we are deprecating them. - - *Tom Meier* - -* `DateTime#to_f` now preserves the fractional seconds instead of always - rounding to `.0`. - - Fixes #15994. - - *John Paul Ashenfelter* - -* Add `Hash#transform_values` to simplify a common pattern where the values of a - hash must change, but the keys are left the same. - - *Sean Griffin* - -* Always instrument `ActiveSupport::Cache`. - - Since `ActiveSupport::Notifications` only instruments items when there - are attached subscribers, we don't need to disable instrumentation. - - *Peter Wagenet* - -* Make the `apply_inflections` method case-insensitive when checking - whether a word is uncountable or not. - - *Robin Dupret* - -* Make Dependencies pass a name to NameError error. - - *arthurnn* - -* Fixed `ActiveSupport::Cache::FileStore` exploding with long paths. - - *Adam Panzer*, *Michael Grosser* - -* Fixed `ActiveSupport::TimeWithZone#-` so precision is not unnecessarily lost - when working with objects with a nanosecond component. - - `ActiveSupport::TimeWithZone#-` should return the same result as if we were - using `Time#-`: - - Time.now.end_of_day - Time.now.beginning_of_day # => 86399.999999999 - - Before: - - Time.zone.now.end_of_day.nsec # => 999999999 - Time.zone.now.end_of_day - Time.zone.now.beginning_of_day # => 86400.0 - - After: - - Time.zone.now.end_of_day - Time.zone.now.beginning_of_day - # => 86399.999999999 - - *Gordon Chan* - -* Fixed precision error in NumberHelper when using Rationals. - - Before: - - ActiveSupport::NumberHelper.number_to_rounded Rational(1000, 3), precision: 2 - # => "330.00" - - After: - - ActiveSupport::NumberHelper.number_to_rounded Rational(1000, 3), precision: 2 - # => "333.33" - - See #15379. - - *Juanjo Bazán* - -* Removed deprecated `Numeric#ago` and friends - - Replacements: - - 5.ago => 5.seconds.ago - 5.until => 5.seconds.until - 5.since => 5.seconds.since - 5.from_now => 5.seconds.from_now - - See #12389 for the history and rationale behind this. - - *Godfrey Chan* - -* DateTime `advance` now supports partial days. - - Before: - - DateTime.now.advance(days: 1, hours: 12) - - After: - - DateTime.now.advance(days: 1.5) - - Fixes #12005. - - *Shay Davidson* - -* `Hash#deep_transform_keys` and `Hash#deep_transform_keys!` now transform hashes - in nested arrays. This change also applies to `Hash#deep_stringify_keys`, - `Hash#deep_stringify_keys!`, `Hash#deep_symbolize_keys` and - `Hash#deep_symbolize_keys!`. - - *OZAWA Sakuro* - -* Fixed confusing `DelegationError` in `Module#delegate`. - - See #15186. - - *Vladimir Yarotsky* - -* Fixed `ActiveSupport::Subscriber` so that no duplicate subscriber is created - when a subscriber method is redefined. - - *Dennis Schön* - -* Remove deprecated string based terminators for `ActiveSupport::Callbacks`. - - *Eileen M. Uchitelle* - -* Fixed an issue when using - `ActiveSupport::NumberHelper::NumberToDelimitedConverter` to - convert a value that is an `ActiveSupport::SafeBuffer` introduced - in 2da9d67. - - See #15064. - - *Mark J. Titorenko* - -* `TimeZone#parse` defaults the day of the month to '1' if any other date - components are specified. This is more consistent with the behavior of - `Time#parse`. - - *Ulysse Carion* - -* `humanize` strips leading underscores, if any. - - Before: - - '_id'.humanize # => "" - - After: - - '_id'.humanize # => "Id" - - *Xavier Noria* - -* Fixed backward compatibility issues introduced in 326e652. - - Empty Hash or Array should not be present in serialization result. - - {a: []}.to_query # => "" - {a: {}}.to_query # => "" - - For more info see #14948. - - *Bogdan Gusiev* - -* Add `Digest::UUID::uuid_v3` and `Digest::UUID::uuid_v5` to support stable - UUID fixtures on PostgreSQL. - - *Roderick van Domburg* - -* Fixed `ActiveSupport::Duration#eql?` so that `1.second.eql?(1.second)` is - true. - - This fixes the current situation of: - - 1.second.eql?(1.second) # => false - - `eql?` also requires that the other object is an `ActiveSupport::Duration`. - This requirement makes `ActiveSupport::Duration`'s behavior consistent with - the behavior of Ruby's numeric types: - - 1.eql?(1.0) # => false - 1.0.eql?(1) # => false - - 1.second.eql?(1) # => false (was true) - 1.eql?(1.second) # => false - - { 1 => "foo", 1.0 => "bar" } - # => { 1 => "foo", 1.0 => "bar" } - - { 1 => "foo", 1.second => "bar" } - # now => { 1 => "foo", 1.second => "bar" } - # was => { 1 => "bar" } - - And though the behavior of these hasn't changed, for reference: - - 1 == 1.0 # => true - 1.0 == 1 # => true - - 1 == 1.second # => true - 1.second == 1 # => true - - *Emily Dobervich* - -* `ActiveSupport::SafeBuffer#prepend` acts like `String#prepend` and modifies - instance in-place, returning self. `ActiveSupport::SafeBuffer#prepend!` is - deprecated. - - *Pavel Pravosud* - -* `HashWithIndifferentAccess` better respects `#to_hash` on objects it - receives. In particular, `.new`, `#update`, `#merge`, and `#replace` accept - objects which respond to `#to_hash`, even if those objects are not hashes - directly. - - *Peter Jaros* - -* Deprecate `Class#superclass_delegating_accessor`, use `Class#class_attribute` instead. - - *Akshay Vishnoi* - -* Ensure classes which `include Enumerable` get `#to_json` in addition to - `#as_json`. - - *Sammy Larbi* - -* Change the signature of `fetch_multi` to return a hash rather than an - array. This makes it consistent with the output of `read_multi`. - - *Parker Selbert* - -* Introduce `Concern#class_methods` as a sleek alternative to clunky - `module ClassMethods`. Add `Kernel#concern` to define at the toplevel - without chunky `module Foo; extend ActiveSupport::Concern` boilerplate. - - # app/models/concerns/authentication.rb - concern :Authentication do - included do - after_create :generate_private_key - end - - class_methods do - def authenticate(credentials) - # ... - end - end - - def generate_private_key - # ... - end - end - - # app/models/user.rb - class User < ActiveRecord::Base - include Authentication - end - - *Jeremy Kemper* - -Please check [4-1-stable](https://github.com/rails/rails/blob/4-1-stable/activesupport/CHANGELOG.md) for previous changes. +Please check [4-2-stable](https://github.com/rails/rails/blob/4-2-stable/activesupport/CHANGELOG.md) for previous changes. diff --git a/activesupport/lib/active_support/gem_version.rb b/activesupport/lib/active_support/gem_version.rb index bc7933e38b..7068f09d87 100644 --- a/activesupport/lib/active_support/gem_version.rb +++ b/activesupport/lib/active_support/gem_version.rb @@ -5,10 +5,10 @@ module ActiveSupport end module VERSION - MAJOR = 4 - MINOR = 2 + MAJOR = 5 + MINOR = 0 TINY = 0 - PRE = "beta4" + PRE = "alpha" STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".") end diff --git a/guides/CHANGELOG.md b/guides/CHANGELOG.md index 2770fc73e7..afaa404ac1 100644 --- a/guides/CHANGELOG.md +++ b/guides/CHANGELOG.md @@ -1,27 +1 @@ -* Change Posts to Articles in Getting Started sample application in order to -better align with the actual guides. - - *John Kelly Ferguson* - -* Update all Rails 4.1.0 references to 4.1.1 within the guides and code. - - *John Kelly Ferguson* - -* Split up rows in the Explain Queries table of the ActiveRecord Querying section -in order to improve readability. - - *John Kelly Ferguson* - -* Change all non-HTTP method 'post' references to 'article'. - - *John Kelly Ferguson* - -* Updates the maintenance policy to match the latest versions of Rails - - *Matias Korhonen* - -* Switched the order of `Applying a default scope` and `Merging of scopes` subsections so default scopes are introduced first. - - *Alex Riabov* - -Please check [4-1-stable](https://github.com/rails/rails/blob/4-1-stable/guides/CHANGELOG.md) for previous changes. +Please check [4-2-stable](https://github.com/rails/rails/blob/4-2-stable/guides/CHANGELOG.md) for previous changes. diff --git a/guides/source/4_2_release_notes.md b/guides/source/4_2_release_notes.md index 848a125bbc..737922c283 100644 --- a/guides/source/4_2_release_notes.md +++ b/guides/source/4_2_release_notes.md @@ -47,7 +47,8 @@ the object itself. The new [Global ID](https://github.com/rails/globalid) library builds URIs and looks up the objects they reference. Passing Active Record objects as job arguments just works by using Global ID internally. -For example, if `trashable` is an AR this job runs just fine +For example, if `trashable` is an Active Record object, then this job runs +just fine with no serialization involved: ```ruby class TrashableCleanupJob < ActiveJob::Base @@ -57,8 +58,6 @@ class TrashableCleanupJob < ActiveJob::Base end ``` -with no serialization involved. - See the [Active Job Basics](active_job_basics.html) guide for more information. @@ -80,9 +79,9 @@ on similar calls, skipping most of the query-generation work on subsequent calls. For more details, please refer to [Aaron Patterson's blog post](http://tenderlovemaking.com/2014/02/19/adequaterecord-pro-like-activerecord.html). -Active Record will automatically take advantage of this feature on the +Active Record will automatically take advantage of this feature on supported operations without any user involvement or code changes. Here are -some examples of the supported operations: +some examples of supported operations: ```ruby Post.find(1) # First call generates and cache the prepared statement @@ -96,10 +95,10 @@ post.comments(true) ``` It's important to highlight that, as the examples above suggest, the prepared -statements do not cache the values passed in the method calls, they rather +statements do not cache the values passed in the method calls; rather, they have placeholders for them. -The caching is not used in the following scenarios: +Caching is not used in the following scenarios: - The model has a default scope - The model uses single table inheritance @@ -119,7 +118,7 @@ The caching is not used in the following scenarios: ### Web Console -New applications generated from Rails 4.2 now come with the [Web +New applications generated with Rails 4.2 now come with the [Web Console](https://github.com/rails/web-console) gem by default. Web Console adds an interactive Ruby console on every error page and provides a `console` view and controller helpers. @@ -167,9 +166,9 @@ The following changes may require immediate action upon upgrade. ### `render` with a String Argument Previously, calling `render "foo/bar"` in a controller action was equivalent to -`render file: "foo/bar"`. In Rails 4.2, this has been changed to mean `render template: "foo/bar"` -instead. If you need to render a file, please change your code to use the -explicit form (`render file: "foo/bar"`) instead. +`render file: "foo/bar"`. In Rails 4.2, this has been changed to mean +`render template: "foo/bar"` instead. If you need to render a file, please +change your code to use the explicit form (`render file: "foo/bar"`) instead. ### `respond_with` / Class-Level `respond_to` @@ -210,8 +209,9 @@ end Due to a [change in Rack](https://github.com/rack/rack/commit/28b014484a8ac0bbb388e7eaeeef159598ec64fc), `rails server` now listens on `localhost` instead of `0.0.0.0` by default. This -should have minimal impact on the standard development workflow as both http://127.0.0.1:3000 -and http://localhost:3000 will continue to work as before on your own machine. +should have minimal impact on the standard development workflow as both +http://127.0.0.1:3000 and http://localhost:3000 will continue to work as before +on your own machine. However, with this change you will no longer be able to access the Rails server from a different machine, for example if your development environment @@ -229,8 +229,8 @@ built upon [Loofah](https://github.com/flavorjones/loofah) and [Nokogiri](https://github.com/sparklemotion/nokogiri). The new sanitizer is more secure and its sanitization is more powerful and flexible. -Due to the new algorithm, sanitized output changes for certain pathological -inputs. +Due to the new algorithm, the sanitized output may be different for certain +pathological inputs. If you have a particular need for the exact output of the old sanitizer, you can add the [rails-deprecated_sanitizer](https://github.com/kaspth/rails-deprecated_sanitizer) @@ -663,8 +663,8 @@ Please refer to the [Changelog][active-record] for detailed changes. current environment. ([Commit](https://github.com/rails/rails/commit/e2f232aba15937a4b9d14bd91e0392c6d55be58d)) -* Introduced `ActiveRecord::Base#validate!` that raises `ActiveRecord::RecordInvalid` if the - record is invalid. +* Introduced `ActiveRecord::Base#validate!` that raises + `ActiveRecord::RecordInvalid` if the record is invalid. ([Pull Request](https://github.com/rails/rails/pull/8639)) * Introduced `validate` as an alias for `valid?`. @@ -704,8 +704,8 @@ Please refer to the [Changelog][active-record] for detailed changes. `SELECT`s. ([Pull Request](https://github.com/rails/rails/pull/15866)) -* `ActiveRecord::Base#reflections` now returns a hash with string keys instead of symbol keys. - ([Pull Request](https://github.com/rails/rails/pull/17718)) +* `ActiveRecord::Base#reflections` now returns a hash with string keys instead + of symbol keys. ([Pull Request](https://github.com/rails/rails/pull/17718)) * The `references` method in migrations now supports a `type` option for specifying the type of the foreign key (e.g. `:uuid`). diff --git a/railties/CHANGELOG.md b/railties/CHANGELOG.md index ff6dcac465..cd7f3b1e2f 100644 --- a/railties/CHANGELOG.md +++ b/railties/CHANGELOG.md @@ -1,208 +1 @@ -* Generated migrations add the appropriate foreign key constraints to - references. - - *Derek Prior* - -* Deprecate different default for `log_level` in production. - - *Godfrey Chan*, *Matthew Draper* - -* Generated `.gitignore` excludes the whole `log/` directory, not only - `*.log` files. - - *ShunsukeAida* - -* `Rails::Paths::Path.unshift` now has the same interface as `Array.unshift`. - - *Igor Kapkov* - -* Make `rake test` run all tests in test folder. - - Deprecate `rake test:all` and replace `rake test:all:db` with `rake test:db` - - *David Geukers* - -* `secret_token` is now saved in `Rails.application.secrets.secret_token` - and it falls back to the value of `config.secret_token` when it is not - present in `config/secrets.yml`. - - *Benjamin Fleischer* - -* Remove `--skip-action-view` option from `Rails::Generators::AppBase`. - - Fixes #17023. - - *Dan Olson* - -* Specify dummy app's db migrate path in plugin's test_helper.rb. - - Fixes #16877. - - *Yukio Mizuta* - -* Inject `Rack::Lock` if `config.eager_load` is false. - - Fixes #15089. - - *Xavier Noria* - -* Change the path of dummy app location in plugin's test_helper.rb for cases - you specify dummy_path option. - - *Yukio Mizuta* - -* Fix a bug in the `gem` method for Rails templates when non-String options - are used. - - Fixes #16709. - - *Yves Senn* - -* The [web-console](https://github.com/rails/web-console) gem is now - installed by default for new applications. It can help you debug - development exceptions by spawning an interactive console in its cause - binding. - - *Ryan Dao*, *Genadi Samokovarov*, *Guillermo Iguaran* - -* Add a `required` option to the model generator for associations - - *Sean Griffin* - -* Add `after_bundle` callbacks in Rails templates. Useful for allowing the - generated binstubs to be added to version control. - - Fixes #16292. - - *Stefan Kanev* - -* Pull in the custom configuration concept from dhh/custom_configuration, which allows you to - configure your own code through the Rails configuration object with custom configuration: - - # config/environments/production.rb - config.x.payment_processing.schedule = :daily - config.x.payment_processing.retries = 3 - config.x.super_debugger = true - - These configuration points are then available through the configuration object: - - Rails.configuration.x.payment_processing.schedule # => :daily - Rails.configuration.x.payment_processing.retries # => 3 - Rails.configuration.x.super_debugger # => true - - *DHH* - -* Scaffold generator `_form` partial adds `class="field"` for password - confirmation fields. - - *noinkling* - -* Add `Rails::Application.config_for` to load a configuration for the current - environment. - - # config/exception_notification.yml: - production: - url: http://127.0.0.1:8080 - namespace: my_app_production - development: - url: http://localhost:3001 - namespace: my_app_development - - # config/production.rb - Rails.application.configure do - config.middleware.use ExceptionNotifier, config_for(:exception_notification) - end - - *Rafael Mendonça França*, *DHH* - -* Deprecate `Rails::Rack::LogTailer` without replacement. - - *Rafael Mendonça França* - -* Add `--skip-turbolinks` option to the app generator. - - *Rafael Mendonça França* - -* Invalid `bin/rails generate` commands will now show spelling suggestions. - - *Richard Schneeman* - -* Add `bin/setup` script to bootstrap an application. - - *Yves Senn* - -* Replace double quotes with single quotes while adding an entry into Gemfile. - - *Alexander Belaev* - -* Default `config.assets.digest` to `true` in development. - - *Dan Kang* - -* Load database configuration from the first `database.yml` available in paths. - - *Pier-Olivier Thibault* - -* Reading name and email from git for plugin gemspec. - - Fixes #9589. - - *Arun Agrawal*, *Abd ar-Rahman Hamidi*, *Roman Shmatov* - -* Fix `console` and `generators` blocks defined at different environments. - - Fixes #14748. - - *Rafael Mendonça França* - -* Move configuration of asset precompile list and version to an initializer. - - *Matthew Draper* - -* Remove sqlite3 lines from `.gitignore` if the application is not using sqlite3. - - *Dmitrii Golub* - -* Add public API to register new extensions for `rake notes`. - - Example: - - config.annotations.register_extensions("scss", "sass") { |tag| /\/\/\s*(#{tag}):?\s*(.*)$/ } - - *Roberto Miranda* - -* Removed unnecessary `rails application` command. - - *Arun Agrawal* - -* Make the `rails:template` rake task load the application's initializers. - - Fixes #12133. - - *Robin Dupret* - -* Introduce `Rails.gem_version` as a convenience method to return - `Gem::Version.new(Rails.version)`, suggesting a more reliable way to perform - version comparison. - - Example: - - Rails.version #=> "4.1.2" - Rails.gem_version #=> #<Gem::Version "4.1.2"> - - Rails.version > "4.1.10" #=> false - Rails.gem_version > Gem::Version.new("4.1.10") #=> true - Gem::Requirement.new("~> 4.1.2") =~ Rails.gem_version #=> true - - *Prem Sichanugrist* - -* Avoid namespacing routes inside engines. - - Mountable engines are namespaced by default so the generated routes - were too while they should not. - - Fixes #14079. - - *Yves Senn*, *Carlos Antonio da Silva*, *Robin Dupret* - -Please check [4-1-stable](https://github.com/rails/rails/blob/4-1-stable/railties/CHANGELOG.md) for previous changes. +Please check [4-2-stable](https://github.com/rails/rails/blob/4-2-stable/railties/CHANGELOG.md) for previous changes. diff --git a/railties/lib/rails/gem_version.rb b/railties/lib/rails/gem_version.rb index 8abed99f2c..7d74b1bfe5 100644 --- a/railties/lib/rails/gem_version.rb +++ b/railties/lib/rails/gem_version.rb @@ -5,10 +5,10 @@ module Rails end module VERSION - MAJOR = 4 - MINOR = 2 + MAJOR = 5 + MINOR = 0 TINY = 0 - PRE = "beta4" + PRE = "alpha" STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".") end diff --git a/railties/lib/rails/generators/app_base.rb b/railties/lib/rails/generators/app_base.rb index 0823b0cc46..f5ae600bd8 100644 --- a/railties/lib/rails/generators/app_base.rb +++ b/railties/lib/rails/generators/app_base.rb @@ -240,8 +240,7 @@ module Rails gems << GemfileEntry.github('sass-rails', 'rails/sass-rails', 'Use SCSS for stylesheets') else - gems << GemfileEntry.version('sass-rails', - '~> 5.0.0.beta1', + gems << GemfileEntry.version('sass-rails', '~> 4.0', 'Use SCSS for stylesheets') end diff --git a/railties/lib/rails/test_unit/testing.rake b/railties/lib/rails/test_unit/testing.rake index 0d0cfa3c6b..254ea9ecf6 100644 --- a/railties/lib/rails/test_unit/testing.rake +++ b/railties/lib/rails/test_unit/testing.rake @@ -10,7 +10,8 @@ end namespace :test do task :prepare do - # Placeholder task for other Railtie and plugins to enhance. See Active Record for an example. + # Placeholder task for other Railtie and plugins to enhance. + # If used with Active Record, this task runs before the database schema is synchronized. end Rails::TestTask.new(:run) do |t| diff --git a/version.rb b/version.rb index 8abed99f2c..7d74b1bfe5 100644 --- a/version.rb +++ b/version.rb @@ -5,10 +5,10 @@ module Rails end module VERSION - MAJOR = 4 - MINOR = 2 + MAJOR = 5 + MINOR = 0 TINY = 0 - PRE = "beta4" + PRE = "alpha" STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".") end |