Browse files

Merge branch 'master' into adequaterecord

* master: (55 commits)
  [ci skip] Move association class method notes
  extract common code in `uuid_test.rb`.
  move PostgreSQL UUID tests from `datatype_test.rb` to `uuid_test.rb`.
  [ci skip] remove guide section on models in migrations
  test case for custom PostgreSQL enum type.
  Remove inclusion of rubysl gem for rbx on generated Gemfile
  let `insert_record` actuall save the object.
  [skip ci] Fix test name typo in app generator tests.
  travis s/2.1.0/2.1.1
  Bump version of bcrypt gem
  Skip test_migrate_revert_add_index_with_name if databases do not allow to create duplicate indexes on the same columns
  Optimize getting started guide images, and use png instead of jpg
  ✂️ [ci skip]
  Point master changelogs to 4-1-stable branch
  Add missing parantheses in index_exists?
  `ActionDispatch::Head` was replaced by `Rack::Head`. Closes #14191.
  [skip ci] Standardized punctuation.
  [skip ci] Fix typo in link_to :method option description
  refactor, with_locale is not needed because I18n is mocked.
  Fix ActionView label translation for more than 10 nested elements
  ...
  • Loading branch information...
2 parents e5e440f + 3225898 commit bf3ddfa28da8ca837ddce8c6744a6c1fd9a51243 @tenderlove tenderlove committed Feb 26, 2014
Showing with 853 additions and 4,484 deletions.
  1. +1 −2 .travis.yml
  2. +5 −1 Gemfile
  3. +1 −1 RAILS_VERSION
  4. +0 −31 RELEASING_RAILS.rdoc
  5. +0 −6 Rakefile
  6. +1 −61 actionmailer/CHANGELOG.md
  7. +3 −3 actionmailer/lib/action_mailer/base.rb
  8. +1 −1 actionmailer/lib/action_mailer/version.rb
  9. +1 −551 actionpack/CHANGELOG.md
  10. +3 −1 actionpack/lib/abstract_controller/rendering.rb
  11. +1 −1 actionpack/lib/action_controller/base.rb
  12. +1 −1 actionpack/lib/action_controller/log_subscriber.rb
  13. +1 −1 actionpack/lib/action_controller/metal/data_streaming.rb
  14. +6 −6 actionpack/lib/action_controller/metal/http_authentication.rb
  15. +1 −1 actionpack/lib/action_controller/metal/strong_parameters.rb
  16. +0 −1 actionpack/lib/action_dispatch.rb
  17. +1 −1 actionpack/lib/action_pack/version.rb
  18. +26 −4 actionpack/test/controller/parameters/log_on_unpermitted_params_test.rb
  19. +1 −327 actionview/CHANGELOG.md
  20. +1 −1 actionview/lib/action_view/helpers/tags/label.rb
  21. +1 −1 actionview/lib/action_view/helpers/url_helper.rb
  22. +1 −1 actionview/lib/action_view/version.rb
  23. +91 −87 actionview/test/template/form_helper_test.rb
  24. +1 −72 activemodel/CHANGELOG.md
  25. +4 −4 activemodel/lib/active_model/secure_password.rb
  26. +1 −1 activemodel/lib/active_model/version.rb
  27. +24 −1,840 activerecord/CHANGELOG.md
  28. +12 −12 activerecord/lib/active_record/associations.rb
  29. +1 −1 activerecord/lib/active_record/associations/association.rb
  30. +3 −7 activerecord/lib/active_record/associations/collection_association.rb
  31. +1 −2 activerecord/lib/active_record/associations/has_many_through_association.rb
  32. +3 −2 activerecord/lib/active_record/attribute_methods.rb
  33. +1 −1 activerecord/lib/active_record/autosave_association.rb
  34. +4 −1 activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb
  35. +1 −1 activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb
  36. +8 −2 activerecord/lib/active_record/connection_adapters/column.rb
  37. +38 −40 activerecord/lib/active_record/connection_adapters/postgresql/oid.rb
  38. +23 −5 activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
  39. +5 −9 activerecord/lib/active_record/connection_handling.rb
  40. +1 −1 activerecord/lib/active_record/fixtures.rb
  41. +1 −1 activerecord/lib/active_record/version.rb
  42. +1 −16 activerecord/test/cases/adapters/postgresql/datatype_test.rb
  43. +38 −0 activerecord/test/cases/adapters/postgresql/enum_test.rb
  44. +84 −23 activerecord/test/cases/adapters/postgresql/range_test.rb
  45. +83 −51 activerecord/test/cases/adapters/postgresql/uuid_test.rb
  46. +21 −0 activerecord/test/cases/associations/callbacks_test.rb
  47. +0 −10 activerecord/test/cases/associations/has_many_associations_test.rb
  48. +7 −0 activerecord/test/cases/associations/has_many_through_associations_test.rb
  49. +37 −11 activerecord/test/cases/attribute_methods_test.rb
  50. +25 −0 activerecord/test/cases/autosave_association_test.rb
  51. +8 −15 activerecord/test/cases/connection_adapters/connection_handler_test.rb
  52. +13 −10 activerecord/test/cases/invertible_migration_test.rb
  53. +18 −0 activerecord/test/cases/scoping/default_scoping_test.rb
  54. +1 −0 activerecord/test/fixtures/computers.yml
  55. +2 −0 activerecord/test/models/developer.rb
  56. +0 −8 activerecord/test/models/pirate.rb
  57. +0 −8 activerecord/test/models/ship.rb
  58. +1 −0 activerecord/test/schema/schema.rb
  59. +18 −622 activesupport/CHANGELOG.md
  60. +2 −32 activesupport/lib/active_support/cache/strategy/local_cache.rb
  61. +39 −0 activesupport/lib/active_support/cache/strategy/local_cache_middleware.rb
  62. +9 −1 activesupport/lib/active_support/concern.rb
  63. +2 −1 activesupport/lib/active_support/core_ext/kernel.rb
  64. +10 −0 activesupport/lib/active_support/core_ext/kernel/concern.rb
  65. +4 −0 activesupport/lib/active_support/core_ext/kernel/reporting.rb
  66. +2 −2 activesupport/lib/active_support/core_ext/object/inclusion.rb
  67. +1 −1 activesupport/lib/active_support/version.rb
  68. +8 −2 activesupport/test/concern_test.rb
  69. +12 −0 activesupport/test/core_ext/kernel/concern_test.rb
  70. +44 −14 activesupport/test/core_ext/module/concerning_test.rb
  71. +3 −3 activesupport/test/core_ext/object/inclusion_test.rb
  72. +1 −13 guides/CHANGELOG.md
  73. BIN guides/assets/images/getting_started/article_with_comments.png
  74. BIN guides/assets/images/getting_started/challenge.png
  75. BIN guides/assets/images/getting_started/confirm_dialog.png
  76. BIN guides/assets/images/getting_started/forbidden_attributes_for_new_article.png
  77. BIN guides/assets/images/getting_started/form_with_errors.png
  78. BIN guides/assets/images/getting_started/index_action_with_edit_link.png
  79. BIN guides/assets/images/getting_started/new_article.png
  80. BIN guides/assets/images/getting_started/rails_welcome.jpg
  81. BIN guides/assets/images/getting_started/rails_welcome.png
  82. BIN guides/assets/images/getting_started/routing_error_no_controller.png
  83. BIN guides/assets/images/getting_started/routing_error_no_route_matches.png
  84. BIN guides/assets/images/getting_started/show_action_for_articles.png
  85. BIN guides/assets/images/getting_started/template_is_missing_articles_new.png
  86. BIN guides/assets/images/getting_started/unknown_action_create_for_articles.png
  87. BIN guides/assets/images/getting_started/unknown_action_new_for_articles.png
  88. +1 −1 guides/code/getting_started/Gemfile
  89. +1 −1 guides/source/_welcome.html.erb
  90. +7 −0 guides/source/api_documentation_guidelines.md
  91. +1 −1 guides/source/asset_pipeline.md
  92. +6 −6 guides/source/getting_started.md
  93. +1 −1 guides/source/layout.html.erb
  94. +0 −153 guides/source/migrations.md
  95. +3 −3 guides/source/plugins.md
  96. +3 −3 guides/source/testing.md
  97. +2 −2 guides/source/upgrading_ruby_on_rails.md
  98. +1 −319 railties/CHANGELOG.md
  99. +1 −5 railties/lib/rails/application/bootstrap.rb
  100. +0 −9 railties/lib/rails/generators/app_base.rb
  101. +28 −0 railties/lib/rails/generators/model_helpers.rb
  102. +1 −1 railties/lib/rails/generators/rails/app/templates/Gemfile
  103. +4 −6 railties/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt
  104. +4 −0 railties/lib/rails/generators/rails/model/model_generator.rb
  105. +2 −11 railties/lib/rails/generators/resource_helpers.rb
  106. +2 −2 railties/lib/rails/version.rb
  107. +1 −14 railties/test/application/configuration_test.rb
  108. +0 −7 railties/test/generators/app_generator_test.rb
  109. +7 −0 railties/test/generators/model_generator_test.rb
  110. +1 −1 railties/test/generators/resource_generator_test.rb
  111. +2 −2 version.rb
View
3 .travis.yml
@@ -5,7 +5,7 @@ before_install:
rvm:
- 1.9.3
- 2.0.0
- - 2.1.0
+ - 2.1.1
- rbx-2
- jruby
env:
@@ -35,4 +35,3 @@ notifications:
bundler_args: --path vendor/bundle --without test
services:
- memcached
-
View
6 Gemfile
@@ -8,12 +8,16 @@ gemspec
gem 'mocha', '~> 0.14', require: false
gem 'rack-cache', '~> 1.2'
-gem 'bcrypt-ruby', '~> 3.1.2'
gem 'jquery-rails', '~> 3.1.0'
gem 'turbolinks'
gem 'coffee-rails', '~> 4.0.0'
gem 'arel', github: 'rails/arel'
+# require: false so bcrypt is loaded only when has_secure_password is used.
+# This is to avoid ActiveModel (and by extension the entire framework)
+# being dependent on a binary library.
+gem 'bcrypt', '~> 3.1.7', require: false
+
# This needs to be with require false to avoid
# it being automatically loaded by sprockets
gem 'uglifier', '>= 1.3.0', require: false
View
2 RAILS_VERSION
@@ -1 +1 @@
-4.1.0.beta2
+4.2.0.alpha
View
31 RELEASING_RAILS.rdoc
@@ -203,34 +203,3 @@ There are two simple steps for fixing the CI:
2. Fix it
Repeat these steps until the CI is green.
-
-=== Manually trigger docs generation
-
-We have a post-receive hook in GitHub that calls the docs server on pushes.
-It triggers generation and publication of edge docs, updates the contrib app,
-and generates and publishes stable docs if a new stable tag is detected.
-
-The hook unfortunately is not invoked by tag pushing, so once the new stable
-tag has been pushed to origin, please run
-
- rake publish_docs
-
-You should see something like this:
-
- Rails master hook tasks scheduled:
-
- * updates the local checkout
- * updates Rails Contributors
- * generates and publishes edge docs
-
- If a new stable tag is detected it also
-
- * generates and publishes stable docs
-
- This needs typically a few minutes.
-
-Note you do not need to specify the tag, the docs server figures it out.
-
-Also, don't worry if you call that multiple times or the hook is triggered
-again by some immediate regular push, if the scripts are running new calls
-are just queued (in a queue of size 1).
View
6 Rakefile
@@ -74,7 +74,6 @@ task :update_versions do
end
end
-#
# We have a webhook configured in GitHub that gets invoked after pushes.
# This hook triggers the following tasks:
#
@@ -84,11 +83,6 @@ end
# * if there's a new stable tag, generates and publishes stable docs
#
# Everything is automated and you do NOT need to run this task normally.
-#
-# We publish a new version by tagging, and pushing a tag does not trigger
-# that webhook. Stable docs would be updated by any subsequent regular
-# push, but if you want that to happen right away just run this.
-#
desc 'Publishes docs, run this AFTER a new stable tag has been pushed'
task :publish_docs do
Net::HTTP.new('api.rubyonrails.org', 8080).start do |http|
View
62 actionmailer/CHANGELOG.md
@@ -1,61 +1 @@
-* Support the use of underscored symbols when registering interceptors and
- observers like we do elsewhere within Rails.
-
- *Andrew White*
-
-* Add the ability to intercept emails before previewing in a similar fashion
- to how emails can be intercepted before delivery.
-
- Fixes #13622.
-
- Example:
-
- class CSSInlineStyler
- def self.previewing_email(message)
- # inline CSS styles
- end
- end
-
- ActionMailer::Base.register_preview_interceptor CSSInlineStyler
-
- *Andrew White*
-
-* Add mailer previews feature based on 37 Signals mail_view gem.
-
- *Andrew White*
-
-* Calling `mail()` without arguments serves as getter for the current mail
- message and keeps previously set headers.
-
- Fixes #13090.
-
- Example:
-
- class MailerWithCallback < ActionMailer::Base
- after_action :a_callback
-
- def welcome
- mail subject: "subject", to: ["joe@example.com"]
- end
-
- def a_callback
- mail # => returns the current mail message
- end
- end
-
- *Yves Senn*
-
-* Instrument the generation of Action Mailer messages. The time it takes to
- generate a message is written to the log.
-
- *Daniel Schierbeck*
-
-* Invoke mailer defaults as procs only if they are procs, do not convert with
- `to_proc`. That an object is convertible to a proc does not mean it's meant
- to be always used as a proc.
-
- Fixes #11533.
-
- *Alex Tsukernik*
-
-Please check [4-0-stable](https://github.com/rails/rails/blob/4-0-stable/actionmailer/CHANGELOG.md) for previous changes.
+Please check [4-1-stable](https://github.com/rails/rails/blob/4-1-stable/actionmailer/CHANGELOG.md) for previous changes.
View
6 actionmailer/lib/action_mailer/base.rb
@@ -724,11 +724,11 @@ def attachments
# format.html
# end
#
- # You can even render text directly without using a template:
+ # You can even render plain text directly without using a template:
#
# mail(to: 'mikel@test.lindsaar.net') do |format|
- # format.text { render text: "Hello Mikel!" }
- # format.html { render text: "<h1>Hello Mikel!</h1>" }
+ # format.text { render plain: "Hello Mikel!" }
+ # format.html { render html: "<h1>Hello Mikel!</h1>".html_safe }
# end
#
# Which will render a +multipart/alternative+ email with +text/plain+ and
View
2 actionmailer/lib/action_mailer/version.rb
@@ -1,7 +1,7 @@
module ActionMailer
# Returns the version of the currently loaded ActionMailer as a Gem::Version
def self.version
- Gem::Version.new "4.1.0.beta2"
+ Gem::Version.new "4.2.0.alpha"
end
module VERSION #:nodoc:
View
552 actionpack/CHANGELOG.md
@@ -1,551 +1 @@
-* Introduce `render :html` as an option to render HTML content with a content
- type of `text/html`. This rendering option calls `ERB::Util.html_escape`
- internally to escape unsafe HTML string, so you will have to mark your
- string as html safe if you have any HTML tag in it.
-
- Please see #12374 for more detail.
-
- *Prem Sichanugrist*
-
-* Introduce `render :plain` as an option to render content with a content type
- of `text/plain`. This is the preferred option if you are planning to render
- a plain text content.
-
- Please see #12374 for more detail.
-
- *Prem Sichanugrist*
-
-* Introduce `render :body` as an option for sending a raw content back to
- browser. Note that this rendering option will unset the default content type
- and does not include "Content-Type" header back in the response.
-
- You should only use this option if you are expecting the "Content-Type"
- header to not be set. More information on "Content-Type" header can be found
- on RFC 2616, section 7.2.1.
-
- Please see #12374 for more detail.
-
- *Prem Sichanugrist*
-
-* Set stream status to 500 (or 400 on BadRequest) when an error is thrown
- before commiting.
-
- Fixes #12552.
-
- *Kevin Casey*
-
-* Add new config option `config.action_dispatch.cookies_serializer` for
- specifying a serializer for the signed and encrypted cookie jars.
-
- The possible values are:
-
- * `:json` - serialize cookie values with `JSON`
- * `:marshal` - serialize cookie values with `Marshal`
- * `:hybrid` - transparently migrate existing `Marshal` cookie values to `JSON`
-
- For new apps `:json` option is added by default and `:marshal` is used
- when no option is specified to maintain backwards compatibility.
-
- *Łukasz Sarnacki*, *Matt Aimonetti*, *Guillermo Iguaran*, *Godfrey Chan*, *Rafael Mendonça França*
-
-* `FlashHash` now behaves like a `HashWithIndifferentAccess`.
-
- *Guillermo Iguaran*
-
-* Set the `:shallow_path` scope option as each scope is generated rather than
- waiting until the `shallow` option is set. Also make the behavior of the
- `:shallow` resource option consistent with the behavior of the `shallow` method.
-
- Fixes #12498.
-
- *Andrew White*, *Aleksi Aalto*
-
-* Properly require `action_view` in `AbstractController::Rendering` to prevent
- uninitialized constant error for `ENCODING_FLAG`.
-
- *Philipe Fatio*
-
-* Do not discard query parameters that form a hash with the same root key as
- the `wrapper_key` for a request using `wrap_parameters`.
-
- *Josh Jordan*
-
-* Ensure that `request.filtered_parameters` is reset between calls to `process`
- in `ActionController::TestCase`.
-
- Fixes #13803.
-
- *Andrew White*
-
-* Fix `rake routes` error when `Rails::Engine` with empty routes is mounted.
-
- Fixes #13810.
-
- *Maurizio De Santis*
-
-* Log which keys were affected by deep munge.
-
- Deep munge solves CVE-2013-0155 security vulnerability, but its
- behaviour is definately confusing, so now at least information
- about for which keys values were set to nil is visible in logs.
-
- *Łukasz Sarnacki*
-
-* Automatically convert dashes to underscores for shorthand routes, e.g:
-
- get '/our-work/latest'
-
- When running `rake routes` you will get the following output:
-
- Prefix Verb URI Pattern Controller#Action
- our_work_latest GET /our-work/latest(.:format) our_work#latest
-
- *Mikko Johansson*
-
-* Automatically convert dashes to underscores for url helpers, e.g:
-
- get '/contact-us' => 'pages#contact'
- get '/about-us' => 'pages#about_us'
-
- When running `rake routes` you will get the following output:
-
- Prefix Verb URI Pattern Controller#Action
- contact_us GET /contact-us(.:format) pages#contact
- about_us GET /about-us(.:format) pages#about_us
-
- *Amr Tamimi*
-
-* Fix stream closing when sending file with `ActionController::Live` included.
-
- Fixes #12381
-
- *Alessandro Diaferia*
-
-* Allow an absolute controller path inside a module scope. Fixes #12777.
-
- Example:
-
- namespace :foo do
- # will route to BarController without the namespace.
- get '/special', to: '/bar#index'
- end
-
-
-* Unique the segment keys array for non-optimized url helpers
-
- In Rails 3.2 you only needed pass an argument for dynamic segment once so
- unique the segment keys array to match the number of args. Since the number
- of args is less than required parts the non-optimized code path is selected.
- This means to benefit from optimized url generation the arg needs to be
- specified as many times as it appears in the path.
-
- Fixes #12808.
-
- *Andrew White*
-
-* Show full route constraints in error message.
-
- When an optimized helper fails to generate, show the full route constraints
- in the error message. Previously it would only show the contraints that were
- required as part of the path.
-
- Fixes #13592.
-
- *Andrew White*
-
-* Use a custom route visitor for optimized url generation. Fixes #13349.
-
- *Andrew White*
-
-* Allow engine root relative redirects using an empty string.
-
- Example:
-
- # application routes.rb
- mount BlogEngine => '/blog'
-
- # engine routes.rb
- get '/welcome' => redirect('')
-
- This now redirects to the path `/blog`, whereas before it would redirect
- to the application root path. In the case of a path redirect or a custom
- redirect if the path returned contains a host then the path is treated as
- absolute. Similarly for option redirects, if the options hash returned
- contains a `:host` or `:domain` key then the path is treated as absolute.
-
- Fixes #7977.
-
- *Andrew White*
-
-* Fix `Encoding::CompatibilityError` when public path is UTF-8
-
- In #5337 we forced the path encoding to ASCII-8BIT to prevent static file handling
- from blowing up before an application has had chance to deal with possibly invalid
- urls. However this has a negative side effect of making it an incompatible encoding
- if the application's public path has UTF-8 characters in it.
-
- To work around the problem we check to see if the path has a valid encoding once
- it has been unescaped. If it is not valid then we can return early since it will
- not match any file anyway.
-
- Fixes #13518.
-
- *Andrew White*
-
-* `ActionController::Parameters#permit!` permits hashes in array values.
-
- *Xavier Noria*
-
-* Converts hashes in arrays of unfiltered params to unpermitted params.
-
- Fixes #13382.
-
- *Xavier Noria*
-
-* New config option to opt out of params "deep munging" that was used to
- address security vulnerability CVE-2013-0155. In your app config:
-
- config.action_dispatch.perform_deep_munge = false
-
- Take care to understand the security risk involved before disabling this.
- [Read more.](https://groups.google.com/forum/#!topic/rubyonrails-security/t1WFuuQyavI)
-
- *Bernard Potocki*
-
-* `rake routes` shows routes defined under assets prefix.
-
- *Ryunosuke SATO*
-
-* Extend cross-site request forgery (CSRF) protection to GET requests with
- JavaScript responses, protecting apps from cross-origin `<script>` tags.
-
- *Jeremy Kemper*
-
-* Fix generating a path for engine inside a resources block.
-
- Fixes #8533.
-
- *Piotr Sarnacki*
-
-* Add `Mime::Type.register "text/vcard", :vcf` to the default list of mime types.
-
- *DHH*
-
-* Remove deprecated `ActionController::RecordIdentifier`, use
- `ActionView::RecordIdentifier` instead.
-
- *kennyj*
-
-* Fix regression when using `ActionView::Helpers::TranslationHelper#translate` with
- `options[:raise]`.
-
- This regression was introduced at ec16ba75a5493b9da972eea08bae630eba35b62f.
-
- *Shota Fukumori (sora_h)*
-
-* Introducing Variants
-
- We often want to render different html/json/xml templates for phones,
- tablets, and desktop browsers. Variants make it easy.
-
- The request variant is a specialization of the request format, like `:tablet`,
- `:phone`, or `:desktop`.
-
- You can set the variant in a `before_action`:
-
- request.variant = :tablet if request.user_agent =~ /iPad/
-
- Respond to variants in the action just like you respond to formats:
-
- respond_to do |format|
- format.html do |html|
- html.tablet # renders app/views/projects/show.html+tablet.erb
- html.phone { extra_setup; render ... }
- end
- end
-
- Provide separate templates for each format and variant:
-
- app/views/projects/show.html.erb
- app/views/projects/show.html+tablet.erb
- app/views/projects/show.html+phone.erb
-
- You can also simplify the variants definition using the inline syntax:
-
- respond_to do |format|
- format.js { render "trash" }
- format.html.phone { redirect_to progress_path }
- format.html.none { render "trash" }
- end
-
- Variants also support common `any`/`all` block that formats have.
-
- It works for both inline:
-
- respond_to do |format|
- format.html.any { render text: "any" }
- format.html.phone { render text: "phone" }
- end
-
- and block syntax:
-
- respond_to do |format|
- format.html do |variant|
- variant.any(:tablet, :phablet){ render text: "any" }
- variant.phone { render text: "phone" }
- end
- end
-
- *Łukasz Strzałkowski*
-
-* Fix render of localized templates without an explicit format using wrong
- content header and not passing correct formats to template due to the
- introduction of the `NullType` for mimes.
-
- Templates like `hello.it.erb` were subject to this issue.
-
- Fixes #13064.
-
- *Angelo Capilleri*, *Carlos Antonio da Silva*
-
-* Try to escape each part of a url correctly when using a redirect route.
-
- Fixes #13110.
-
- *Andrew White*
-
-* Better error message for typos in assert_response argument.
-
- When the response type argument to `assert_response` is not a known
- response type, `assert_response` now throws an ArgumentError with a clear
- message. This is intended to help debug typos in the response type.
-
- *Victor Costan*
-
-* Fix formatting for `rake routes` when a section is shorter than a header.
-
- *Sıtkı Bağdat*
-
-* Take a hash with options inside array in `#url_for`.
-
- Example:
-
- url_for [:new, :admin, :post, { param: 'value' }]
- # => http://example.com/admin/posts/new?param=value
-
- *Andrey Ognevsky*
-
-* Add `session#fetch` method
-
- fetch behaves like [Hash#fetch](http://www.ruby-doc.org/core-1.9.3/Hash.html#method-i-fetch).
- It returns a value from the hash for the given key.
- If the key can’t be found, there are several options:
-
- * With no other arguments, it will raise an KeyError exception.
- * If a default value is given, then that will be returned.
- * If the optional code block is specified, then that will be run and its result returned.
-
- *Damien Mathieu*
-
-* Don't let strong parameters mutate the given hash via `fetch`
-
- Create a new instance if the given parameter is a `Hash` instead of
- passing it to the `convert_hashes_to_parameters` method since it is
- overriding its default value.
-
- *Brendon Murphy*, *Doug Cole*
-
-* Add `params` option to `button_to` form helper, which renders the given hash
- as hidden form fields.
-
- *Andy Waite*
-
-* Make assets helpers work in the controllers like it works in the views.
-
- Example:
-
- # config/application.rb
- config.asset_host = 'http://mycdn.com'
-
- ActionController::Base.helpers.asset_path('fallback.png')
- # => http://mycdn.com/assets/fallback.png
-
- Fixes #10051.
-
- *Tima Maslyuchenko*
-
-* Respect `SCRIPT_NAME` when using `redirect` with a relative path
-
- Example:
-
- # application routes.rb
- mount BlogEngine => '/blog'
-
- # engine routes.rb
- get '/admin' => redirect('admin/dashboard')
-
- This now redirects to the path `/blog/admin/dashboard`, whereas before it would've
- generated an invalid url because there would be no slash between the host name and
- the path. It also allows redirects to work where the application is deployed to a
- subdirectory of a website.
-
- Fixes #7977.
-
- *Andrew White*
-
-* Fixing repond_with working directly on the options hash
- This fixes an issue where the respond_with worked directly with the given
- options hash, so that if a user relied on it after calling respond_with,
- the hash wouldn't be the same.
-
- Fixes #12029.
-
- *bluehotdog*
-
-* Fix `ActionDispatch::RemoteIp::GetIp#calculate_ip` to only check for spoofing
- attacks if both `HTTP_CLIENT_IP` and `HTTP_X_FORWARDED_FOR` are set.
-
- Fixes #10844.
-
- *Tamir Duberstein*
-
-* Strong parameters should permit nested number as key.
-
- Fixes #12293.
-
- *kennyj*
-
-* Fix regex used to detect URI schemes in `redirect_to` to be consistent with
- RFC 3986.
-
- *Derek Prior*
-
-* Fix incorrect `assert_redirected_to` failure message for protocol-relative
- URLs.
-
- *Derek Prior*
-
-* Fix an issue where router can't recognize downcased url encoding path.
-
- Fixes #12269.
-
- *kennyj*
-
-* Fix custom flash type definition. Misusage of the `_flash_types` class variable
- caused an error when reloading controllers with custom flash types.
-
- Fixes #12057.
-
- *Ricardo de Cillo*
-
-* Do not break params filtering on `nil` values.
-
- Fixes #12149.
-
- *Vasiliy Ermolovich*
-
-* Development mode exceptions are rendered in text format in case of XHR request.
-
- *Kir Shatrov*
-
-* Fix an issue where :if and :unless controller action procs were being run
- before checking for the correct action in the :only and :unless options.
-
- Fixes #11799.
-
- *Nicholas Jakobsen*
-
-* Fix an issue where `assert_dom_equal` and `assert_dom_not_equal` were
- ignoring the passed failure message argument.
-
- Fixes #11751.
-
- *Ryan McGeary*
-
-* Allow REMOTE_ADDR, HTTP_HOST and HTTP_USER_AGENT to be overridden from
- the environment passed into `ActionDispatch::TestRequest.new`.
-
- Fixes #11590.
-
- *Andrew White*
-
-* Fix an issue where Journey was failing to clear the named routes hash when the
- routes were reloaded and since it doesn't overwrite existing routes then if a
- route changed but wasn't renamed it kept the old definition. This was being
- masked by the optimised url helpers so it only became apparent when passing an
- options hash to the url helper.
-
- *Andrew White*
-
-* Skip routes pointing to a redirect or mounted application when generating urls
- using an options hash as they aren't relevant and generate incorrect urls.
-
- Fixes #8018.
-
- *Andrew White*
-
-* Move `MissingHelperError` out of the `ClassMethods` module.
-
- *Yves Senn*
-
-* Fix an issue where rails raise exception about missing helper where it
- should throw `LoadError`. When helper file exists and only loaded file from
- this helper does not exist rails should throw LoadError instead of
- `MissingHelperError`.
-
- *Piotr Niełacny*
-
-* Fix `ActionDispatch::ParamsParser#parse_formatted_parameters` to rewind body input stream on
- parsing json params.
-
- Fixes #11345.
-
- *Yuri Bol*, *Paul Nikitochkin*
-
-* Ignore spaces around delimiter in Set-Cookie header.
-
- *Yamagishi Kazutoshi*
-
-* Remove deprecated Rails application fallback for integration testing, set
- `ActionDispatch.test_app` instead.
-
- *Carlos Antonio da Silva*
-
-* Remove deprecated `page_cache_extension` config.
-
- *Francesco Rodriguez*
-
-* Remove deprecated constants from Action Controller:
-
- ActionController::AbstractRequest => ActionDispatch::Request
- ActionController::Request => ActionDispatch::Request
- ActionController::AbstractResponse => ActionDispatch::Response
- ActionController::Response => ActionDispatch::Response
- ActionController::Routing => ActionDispatch::Routing
- ActionController::Integration => ActionDispatch::Integration
- ActionController::IntegrationTest => ActionDispatch::IntegrationTest
-
- *Carlos Antonio da Silva*
-
-* Fix `Mime::Type.parse` when bad accepts header is looked up. Previously it
- was setting `request.formats` with an array containing a `nil` value, which
- raised an error when setting the controller formats.
-
- Fixes #10965.
-
- *Becker*
-
-* Merge `:action` from routing scope and assign endpoint if both `:controller`
- and `:action` are present. The endpoint assignment only occurs if there is
- no `:to` present in the options hash so should only affect routes using the
- shorthand syntax (i.e. endpoint is inferred from the path).
-
- Fixes #9856.
-
- *Yves Senn*, *Andrew White*
-
-* Action View extracted from Action Pack.
-
- *Piotr Sarnacki*, *Łukasz Strzałkowski*
-
-Please check [4-0-stable](https://github.com/rails/rails/blob/4-0-stable/actionpack/CHANGELOG.md) for previous changes.
+Please check [4-1-stable](https://github.com/rails/rails/blob/4-1-stable/actionpack/CHANGELOG.md) for previous changes.
View
4 actionpack/lib/abstract_controller/rendering.rb
@@ -106,7 +106,9 @@ def _process_format(format, options = {})
def _normalize_render(*args, &block)
options = _normalize_args(*args, &block)
#TODO: remove defined? when we restore AP <=> AV dependency
- options[:variant] = request.variant if defined?(request) && request.variant.present?
+ if defined?(request) && request && request.variant.present?
+ options[:variant] = request.variant
+ end
_normalize_options(options)
options
end
View
2 actionpack/lib/action_controller/base.rb
@@ -45,7 +45,7 @@ module ActionController
#
# def server_ip
# location = request.env["SERVER_ADDR"]
- # render text: "This server hosted at #{location}"
+ # render plain: "This server hosted at #{location}"
# end
#
# == Parameters
View
2 actionpack/lib/action_controller/log_subscriber.rb
@@ -50,7 +50,7 @@ def send_data(event)
def unpermitted_parameters(event)
unpermitted_keys = event.payload[:keys]
- debug("Unpermitted parameters: #{unpermitted_keys.join(", ")}")
+ debug("Unpermitted parameter#{'s' if unpermitted_keys.size > 1}: #{unpermitted_keys.join(", ")}")
end
def deep_munge(event)
View
2 actionpack/lib/action_controller/metal/data_streaming.rb
@@ -96,7 +96,7 @@ def each
end
# Sends the given binary data to the browser. This method is similar to
- # <tt>render text: data</tt>, but also allows you to specify whether
+ # <tt>render plain: data</tt>, but also allows you to specify whether
# the browser should display the response as a file attachment (i.e. in a
# download dialog) or as inline data. You may also set the content type,
# the apparent file name, and other things.
View
12 actionpack/lib/action_controller/metal/http_authentication.rb
@@ -11,11 +11,11 @@ module HttpAuthentication
# http_basic_authenticate_with name: "dhh", password: "secret", except: :index
#
# def index
- # render text: "Everyone can see me!"
+ # render plain: "Everyone can see me!"
# end
#
# def edit
- # render text: "I'm only accessible if you know the password"
+ # render plain: "I'm only accessible if you know the password"
# end
# end
#
@@ -127,11 +127,11 @@ def authentication_request(controller, realm)
# before_action :authenticate, except: [:index]
#
# def index
- # render text: "Everyone can see me!"
+ # render plain: "Everyone can see me!"
# end
#
# def edit
- # render text: "I'm only accessible if you know the password"
+ # render plain: "I'm only accessible if you know the password"
# end
#
# private
@@ -321,11 +321,11 @@ def opaque(secret_key)
# before_action :authenticate, except: [ :index ]
#
# def index
- # render text: "Everyone can see me!"
+ # render plain: "Everyone can see me!"
# end
#
# def edit
- # render text: "I'm only accessible if you know the password"
+ # render plain: "I'm only accessible if you know the password"
# end
#
# private
View
2 actionpack/lib/action_controller/metal/strong_parameters.rb
@@ -32,7 +32,7 @@ class UnpermittedParameters < IndexError
def initialize(params) # :nodoc:
@params = params
- super("found unpermitted parameters: #{params.join(", ")}")
+ super("found unpermitted parameter#{'s' if params.size > 1 }: #{params.join(", ")}")
end
end
View
1 actionpack/lib/action_dispatch.rb
@@ -52,7 +52,6 @@ class IllegalStateError < StandardError
autoload :DebugExceptions
autoload :ExceptionWrapper
autoload :Flash
- autoload :Head
autoload :ParamsParser
autoload :PublicExceptions
autoload :Reloader
View
2 actionpack/lib/action_pack/version.rb
@@ -1,7 +1,7 @@
module ActionPack
# Returns the version of the currently loaded ActionPack as a Gem::Version
def self.version
- Gem::Version.new "4.1.0.beta2"
+ Gem::Version.new "4.2.0.alpha"
end
module VERSION #:nodoc:
View
30 actionpack/test/controller/parameters/log_on_unpermitted_params_test.rb
@@ -10,23 +10,45 @@ def teardown
ActionController::Parameters.action_on_unpermitted_parameters = false
end
- test "logs on unexpected params" do
+ test "logs on unexpected param" do
params = ActionController::Parameters.new({
book: { pages: 65 },
fishing: "Turnips"
})
- assert_logged("Unpermitted parameters: fishing") do
+ assert_logged("Unpermitted parameter: fishing") do
params.permit(book: [:pages])
end
end
- test "logs on unexpected nested params" do
+ test "logs on unexpected params" do
+ params = ActionController::Parameters.new({
+ book: { pages: 65 },
+ fishing: "Turnips",
+ car: "Mersedes"
+ })
+
+ assert_logged("Unpermitted parameters: fishing, car") do
+ params.permit(book: [:pages])
+ end
+ end
+
+ test "logs on unexpected nested param" do
params = ActionController::Parameters.new({
book: { pages: 65, title: "Green Cats and where to find then." }
})
- assert_logged("Unpermitted parameters: title") do
+ assert_logged("Unpermitted parameter: title") do
+ params.permit(book: [:pages])
+ end
+ end
+
+ test "logs on unexpected nested params" do
+ params = ActionController::Parameters.new({
+ book: { pages: 65, title: "Green Cats and where to find then.", author: "G. A. Dog" }
+ })
+
+ assert_logged("Unpermitted parameters: title, author") do
params.permit(book: [:pages])
end
end
View
328 actionview/CHANGELOG.md
@@ -1,327 +1 @@
-* Added `:plain`, `:html` and `:body` option for `render` method. Please see
- Action Pack's release note for more detail.
-
- *Prem Sichanugrist*
-
-* Date select helpers accept a format string for the months selector via the
- new option `:month_format_string`.
-
- When rendered, the format string gets passed keys `:number` (integer), and
- `:name` (string), in order to be able to interpolate them as in
-
- '%{name} (%<number>02d)'
-
- for example.
-
- This option is motivated by #13618.
-
- *Xavier Noria*
-
-* Added `config.action_view.raise_on_missing_translations` to define whether an
- error should be raised for missing translations.
-
- Fixes #13196.
-
- *Kassio Borges*
-
-* Improved ERB dependency detection. New argument types and formattings for the `render`
- calls can be matched.
-
- Fixes #13074, #13116.
-
- *João Britto*
-
-* Use `display:none` instead of `display:inline` for hidden fields.
-
- Fixes #6403.
-
- *Gaelian Ditchburn*
-
-* The `video_tag` helper accepts a number as `:size`.
-
- The `:size` option of the `video_tag` helper now can be specified
- with a stringified number. The `width` and `height` attributes of
- the generated tag will be the same.
-
- *Kuldeep Aggarwal*
-
-* Escape format, negative_format and units options of number helpers
-
- Fixes: CVE-2014-0081
-
-* A Cycle object should accept an array and cycle through it as it would with a set of
- comma-separated objects.
-
- arr = [1,2,3]
- cycle(arr) # => '1'
- cycle(arr) # => '2'
- cycle(arr) # => '3'
-
- Previously, it would return the array as a string, because it took the array as a
- single object:
-
- arr = [1,2,3]
- cycle(arr) # => '[1,2,3]'
- cycle(arr) # => '[1,2,3]'
- cycle(arr) # => '[1,2,3]'
-
- *Kristian Freeman*
-
-* Label tags generated by collection helpers only inherit the `:index` and
- `:namespace` from the input, because only these attributes modifies the
- `for` attribute of the label. Also, the input attributes don't have
- precedence over the label attributes anymore.
-
- Before:
-
- collection = [[1, true, { class: 'foo' }]]
- f.collection_check_boxes :options, collection, :second, :first do |b|
- b.label(class: 'my_custom_class')
- end
-
- # => <label class="foo" for="user_active_true">1</label>
-
- After:
-
- collection = [[1, true, { class: 'foo' }]]
- f.collection_check_boxes :options, collection, :second, :first do |b|
- b.label(class: 'my_custom_class')
- end
-
- # => <label class="my_custom_class" for="user_active_true">1</label>
-
- *Andriel Nuernberg*
-
-* Fixed a long-standing bug in `json_escape` that causes quotation marks to be stripped.
- This method also escapes the \u2028 and \u2029 unicode newline characters which are
- treated as \n in JavaScript. This matches the behaviour of the AS::JSON encoder. (The
- original change in the encoder was introduced in #10534.)
-
- *Godfrey Chan*
-
-* `ActionView::MissingTemplate` includes underscore when raised for a partial.
-
- Fixes #13002.
-
- *Yves Senn*
-
-* Use `set_backtrace` instead of instance variable `@backtrace` in ActionView exceptions.
-
- *Shimpei Makimoto*
-
-* Fix `simple_format` escapes own output when passing `sanitize: true`.
-
- *Paul Seidemann*
-
-* Ensure `ActionView::Digestor.cache` is correctly cleaned up when
- combining recursive templates with `ActionView::Resolver.caching = false`.
-
- *wyaeld*
-
-* Fix `collection_check_boxes` generated hidden input to use the name attribute provided
- in the options hash.
-
- *Angel N. Sciortino*
-
-* Fix some edge cases for AV `select` helper with `:selected` option.
-
- *Bogdan Gusiev*
-
-* Ability to pass a block to the `select` helper.
-
- Example:
-
- <%= select(report, "campaign_ids") do %>
- <% available_campaigns.each do |c| -%>
- <%= content_tag(:option, c.name, value: c.id, data: { tags: c.tags.to_json }) %>
- <% end -%>
- <% end -%>
-
- *Bogdan Gusiev*
-
-* Handle `:namespace` form option in collection labels.
-
- *Vasiliy Ermolovich*
-
-* Fix `form_for` when both `namespace` and `as` options are present.
-
- `as` option no longer overwrites `namespace` option when generating
- html id attribute of the form element.
-
- *Adam Niedzielski*
-
-* Fix `excerpt` when `:separator` is `nil`.
-
- *Paul Nikitochkin*
-
-* Only cache template digests if `config.cache_template_loading` is true.
-
- *Josh Lauer*, *Justin Ridgewell*
-
-* Fixed a bug where the lookup details were not being taken into account
- when caching the digest of a template - changes to the details now
- cause a different cache key to be used.
-
- *Daniel Schierbeck*
-
-* Added an `extname` hash option for `javascript_include_tag` method.
-
- Before:
-
- javascript_include_tag('templates.jst')
- # => <script src="/javascripts/templates.jst.js"></script>
-
- After:
-
- javascript_include_tag('templates.jst', extname: false )
- # => <script src="/javascripts/templates.jst"></script>
-
- *Nathan Stitt*
-
-* Fix `current_page?` when the URL contains escaped characters and the
- original URL is using the hexadecimal lowercased.
-
- *Rafael Mendonça França*
-
-* Fix `text_area` to behave like `text_field` when `nil` is given as
- value.
-
- Before:
-
- f.text_field :field, value: nil #=> <input value="">
- f.text_area :field, value: nil #=> <textarea>value of field</textarea>
-
- After:
-
- f.text_area :field, value: nil #=> <textarea></textarea>
-
- *Joel Cogen*
-
-* Element of the `grouped_options_for_select` can
- optionally contain html attributes as the last element of the array.
-
- grouped_options_for_select(
- [["North America", [['United States','US'],"Canada"], data: { foo: 'bar' }]]
- )
-
- *Vasiliy Ermolovich*
-
-* Fix default rendered format problem when calling `render` without :content_type option.
- It should return :html. Fix #11393.
-
- *Gleb Mazovetskiy*, *Oleg*, *kennyj*
-
-* Fix `link_to` with block and url hashes.
-
- Before:
-
- link_to(action: 'bar', controller: 'foo') { content_tag(:span, 'Example site') }
- # => "<a action=\"bar\" controller=\"foo\"><span>Example site</span></a>"
-
- After:
-
- link_to(action: 'bar', controller: 'foo') { content_tag(:span, 'Example site') }
- # => "<a href=\"/foo/bar\"><span>Example site</span></a>"
-
- *Murahashi Sanemat Kenichi*
-
-* Fix "Stack Level Too Deep" error when redering recursive partials.
-
- Fixes #11340.
-
- *Rafael Mendonça França*
-
-* Added an `enforce_utf8` hash option for `form_tag` method.
-
- Control to output a hidden input tag with name `utf8` without monkey
- patching.
-
- Before:
-
- form_tag
- # => '<form>..<input name="utf8" type="hidden" value="&#x2713;" />..</form>'
-
- After:
-
- form_tag
- # => '<form>..<input name="utf8" type="hidden" value="&#x2713;" />..</form>'
-
- form_tag({}, { :enforce_utf8 => false })
- # => '<form>....</form>'
-
- *ma2gedev*
-
-* Remove the deprecated `include_seconds` argument from `distance_of_time_in_words`,
- pass in an `:include_seconds` hash option to use this feature.
-
- *Carlos Antonio da Silva*
-
-* Remove deprecated block passing to `FormBuilder#new`.
-
- *Vipul A M*
-
-* Pick `DateField` `DateTimeField` and `ColorField` values from stringified options allowing use of symbol keys with helpers.
-
- *Jon Rowe*
-
-* Remove the deprecated `prompt` argument from `grouped_options_for_select`,
- pass in a `:prompt` hash option to use this feature.
-
- *kennyj*
-
-* Always escape the result of `link_to_unless` method.
-
- Before:
-
- link_to_unless(true, '<b>Showing</b>', 'github.com')
- # => "<b>Showing</b>"
-
- After:
-
- link_to_unless(true, '<b>Showing</b>', 'github.com')
- # => "&lt;b&gt;Showing&lt;/b&gt;"
-
- *dtaniwaki*
-
-* Use a case insensitive URI Regexp for #asset_path.
-
- This fix a problem where the same asset path using different case are generating
- different URIs.
-
- Before:
-
- image_tag("HTTP://google.com")
- # => "<img alt=\"Google\" src=\"/assets/HTTP://google.com\" />"
- image_tag("http://google.com")
- # => "<img alt=\"Google\" src=\"http://google.com\" />"
-
- After:
-
- image_tag("HTTP://google.com")
- # => "<img alt=\"Google\" src=\"HTTP://google.com\" />"
- image_tag("http://google.com")
- # => "<img alt=\"Google\" src=\"http://google.com\" />"
-
- *David Celis*
-
-* Element of the `collection_check_boxes` and `collection_radio_buttons` can
- optionally contain html attributes as the last element of the array.
-
- *Vasiliy Ermolovich*
-
-* Update the HTML `BOOLEAN_ATTRIBUTES` in `ActionView::Helpers::TagHelper`
- to conform to the latest HTML 5.1 spec. Add attributes `allowfullscreen`,
- `default`, `inert`, `sortable`, `truespeed`, `typemustmatch`. Fix attribute
- `seamless` (previously misspelled `seemless`).
-
- *Alex Peattie*
-
-* Fix an issue where partials with a number in the filename weren't being digested for cache dependencies.
-
- *Bryan Ricker*
-
-* First release, ActionView extracted from ActionPack
-
- *Piotr Sarnacki*, *Łukasz Strzałkowski*
-
-Please check [4-0-stable (ActionPack's CHANGELOG)](https://github.com/rails/rails/blob/4-0-stable/actionpack/CHANGELOG.md) for previous changes.
+Please check [4-1-stable](https://github.com/rails/rails/blob/4-1-stable/actionview/CHANGELOG.md) for previous changes.
View
2 actionview/lib/action_view/helpers/tags/label.rb
@@ -36,7 +36,7 @@ def render(&block)
content = @template_object.capture(&block)
else
content = if @content.blank?
- @object_name.gsub!(/\[(.*)_attributes\]\[\d\]/, '.\1')
+ @object_name.gsub!(/\[(.*)_attributes\]\[\d+\]/, '.\1')
method_and_value = tag_value.present? ? "#{@method_name}.#{tag_value}" : @method_name
if object.respond_to?(:to_model)
View
2 actionview/lib/action_view/helpers/url_helper.rb
@@ -82,7 +82,7 @@ def _back_url # :nodoc:
# to using GET. If <tt>href: '#'</tt> is used and the user has JavaScript
# disabled clicking the link will have no effect. If you are relying on the
# POST behavior, you should check for it in your controller's action by using
- # the request object's methods for <tt>post?</tt>, <tt>delete?</tt>, <tt>:patch</tt>, or <tt>put?</tt>.
+ # the request object's methods for <tt>post?</tt>, <tt>delete?</tt>, <tt>patch?</tt>, or <tt>put?</tt>.
# * <tt>remote: true</tt> - This will allow the unobtrusive JavaScript
# driver to make an Ajax request to the URL in question instead of following
# the link. The drivers each provide mechanisms for listening for the
View
2 actionview/lib/action_view/version.rb
@@ -1,7 +1,7 @@
module ActionView
# Returns the version of the currently loaded ActionView as a Gem::Version
def self.version
- Gem::Version.new "4.1.0.beta2"
+ Gem::Version.new "4.2.0.alpha"
end
module VERSION #:nodoc:
View
178 actionview/test/template/form_helper_test.rb
@@ -143,75 +143,68 @@ def test_label_with_symbols
end
def test_label_with_locales_strings
- old_locale, I18n.locale = I18n.locale, :label
- assert_dom_equal('<label for="post_body">Write entire text here</label>', label("post", "body"))
- ensure
- I18n.locale = old_locale
+ with_locale :label do
+ assert_dom_equal('<label for="post_body">Write entire text here</label>', label("post", "body"))
+ end
end
def test_label_with_human_attribute_name
- old_locale, I18n.locale = I18n.locale, :label
- assert_dom_equal('<label for="post_cost">Total cost</label>', label(:post, :cost))
- ensure
- I18n.locale = old_locale
+ with_locale :label do
+ assert_dom_equal('<label for="post_cost">Total cost</label>', label(:post, :cost))
+ end
end
def test_label_with_locales_symbols
- old_locale, I18n.locale = I18n.locale, :label
- assert_dom_equal('<label for="post_body">Write entire text here</label>', label(:post, :body))
- ensure
- I18n.locale = old_locale
+ with_locale :label do
+ assert_dom_equal('<label for="post_body">Write entire text here</label>', label(:post, :body))
+ end
end
def test_label_with_locales_and_options
- old_locale, I18n.locale = I18n.locale, :label
- assert_dom_equal(
- '<label for="post_body" class="post_body">Write entire text here</label>',
- label(:post, :body, class: "post_body")
- )
- ensure
- I18n.locale = old_locale
+ with_locale :label do
+ assert_dom_equal(
+ '<label for="post_body" class="post_body">Write entire text here</label>',
+ label(:post, :body, class: "post_body")
+ )
+ end
end
def test_label_with_locales_and_value
- old_locale, I18n.locale = I18n.locale, :label
- assert_dom_equal('<label for="post_color_red">Rojo</label>', label(:post, :color, value: "red"))
- ensure
- I18n.locale = old_locale
+ with_locale :label do
+ assert_dom_equal('<label for="post_color_red">Rojo</label>', label(:post, :color, value: "red"))
+ end
end
def test_label_with_locales_and_nested_attributes
- old_locale, I18n.locale = I18n.locale, :label
- form_for(@post, html: { id: 'create-post' }) do |f|
- f.fields_for(:comments) do |cf|
- concat cf.label(:body)
+ with_locale :label do
+ form_for(@post, html: { id: 'create-post' }) do |f|
+ f.fields_for(:comments) do |cf|
+ concat cf.label(:body)
+ end
end
- end
- expected = whole_form("/posts/123", "create-post", "edit_post", method: "patch") do
- '<label for="post_comments_attributes_0_body">Write body here</label>'
- end
+ expected = whole_form("/posts/123", "create-post", "edit_post", method: "patch") do
+ '<label for="post_comments_attributes_0_body">Write body here</label>'
+ end
- assert_dom_equal expected, output_buffer
- ensure
- I18n.locale = old_locale
+ assert_dom_equal expected, output_buffer
+ end
end
def test_label_with_locales_fallback_and_nested_attributes
- old_locale, I18n.locale = I18n.locale, :label
- form_for(@post, html: { id: 'create-post' }) do |f|
- f.fields_for(:tags) do |cf|
- concat cf.label(:value)
+ with_locale :label do
+ form_for(@post, html: { id: 'create-post' }) do |f|
+ f.fields_for(:tags) do |cf|
+ concat cf.label(:value)
+ end
end
- end
- expected = whole_form("/posts/123", "create-post", "edit_post", method: "patch") do
- '<label for="post_tags_attributes_0_value">Tag</label>'
- end
+ expected = whole_form("/posts/123", "create-post", "edit_post", method: "patch") do
+ '<label for="post_tags_attributes_0_value">Tag</label>'
+ end
- assert_dom_equal expected, output_buffer
- ensure
- I18n.locale = old_locale
+ assert_dom_equal expected, output_buffer
+ end
end
def test_label_with_for_attribute_as_symbol
@@ -1811,69 +1804,61 @@ def test_fields_for_with_namespace
end
def test_submit_with_object_as_new_record_and_locale_strings
- old_locale, I18n.locale = I18n.locale, :submit
+ with_locale :submit do
+ @post.persisted = false
+ @post.stubs(:to_key).returns(nil)
+ form_for(@post) do |f|
+ concat f.submit
+ end
- @post.persisted = false
- @post.stubs(:to_key).returns(nil)
- form_for(@post) do |f|
- concat f.submit
- end
+ expected = whole_form('/posts', 'new_post', 'new_post') do
+ "<input name='commit' type='submit' value='Create Post' />"
+ end
- expected = whole_form('/posts', 'new_post', 'new_post') do
- "<input name='commit' type='submit' value='Create Post' />"
+ assert_dom_equal expected, output_buffer
end
-
- assert_dom_equal expected, output_buffer
- ensure
- I18n.locale = old_locale
end
def test_submit_with_object_as_existing_record_and_locale_strings
- old_locale, I18n.locale = I18n.locale, :submit
+ with_locale :submit do
+ form_for(@post) do |f|
+ concat f.submit
+ end
- form_for(@post) do |f|
- concat f.submit
- end
+ expected = whole_form('/posts/123', 'edit_post_123', 'edit_post', method: 'patch') do
+ "<input name='commit' type='submit' value='Confirm Post changes' />"
+ end
- expected = whole_form('/posts/123', 'edit_post_123', 'edit_post', method: 'patch') do
- "<input name='commit' type='submit' value='Confirm Post changes' />"
+ assert_dom_equal expected, output_buffer
end
-
- assert_dom_equal expected, output_buffer
- ensure
- I18n.locale = old_locale
end
def test_submit_without_object_and_locale_strings
- old_locale, I18n.locale = I18n.locale, :submit
+ with_locale :submit do
+ form_for(:post) do |f|
+ concat f.submit class: "extra"
+ end
- form_for(:post) do |f|
- concat f.submit class: "extra"
- end
+ expected = whole_form do
+ "<input name='commit' class='extra' type='submit' value='Save changes' />"
+ end
- expected = whole_form do
- "<input name='commit' class='extra' type='submit' value='Save changes' />"
+ assert_dom_equal expected, output_buffer
end
-
- assert_dom_equal expected, output_buffer
- ensure
- I18n.locale = old_locale
end
def test_submit_with_object_and_nested_lookup
- old_locale, I18n.locale = I18n.locale, :submit
+ with_locale :submit do
+ form_for(@post, as: :another_post) do |f|
+ concat f.submit
+ end
- form_for(@post, as: :another_post) do |f|
- concat f.submit
- end
+ expected = whole_form('/posts/123', 'edit_another_post', 'edit_another_post', method: 'patch') do
+ "<input name='commit' type='submit' value='Update your Post' />"
+ end
- expected = whole_form('/posts/123', 'edit_another_post', 'edit_another_post', method: 'patch') do
- "<input name='commit' type='submit' value='Update your Post' />"
+ assert_dom_equal expected, output_buffer
end
-
- assert_dom_equal expected, output_buffer
- ensure
- I18n.locale = old_locale
end
def test_nested_fields_for
@@ -2405,6 +2390,18 @@ def test_nested_fields_for_arel_like
assert_dom_equal expected, output_buffer
end
+ def test_nested_fields_label_translation_with_more_than_10_records
+ @post.comments = Array.new(11) { |id| Comment.new(id + 1) }
+
+ I18n.expects(:t).with('post.comments.body', default: [:"comment.body", ''], scope: "helpers.label").times(11).returns "Write body here"
+
+ form_for(@post) do |f|
+ f.fields_for(:comments) do |cf|
+ concat cf.label(:body)
+ end
+ end
+ end
+
def test_nested_fields_for_with_existing_records_on_a_supplied_nested_attributes_collection_different_from_record_one
comments = Array.new(2) { |id| Comment.new(id + 1) }
@post.comments = []
@@ -3052,4 +3049,11 @@ def whole_form(action = "/", id = nil, html_class = nil, options = {})
def protect_against_forgery?
false
end
+
+ def with_locale(testing_locale = :label)
+ old_locale, I18n.locale = I18n.locale, testing_locale
+ yield
+ ensure
+ I18n.locale = old_locale
+ end
end
View
73 activemodel/CHANGELOG.md
@@ -1,72 +1 @@
-* `#to_param` returns `nil` if `#to_key` returns `nil`. Fixes #11399.
-
- *Yves Senn*
-
-* Ability to specify multiple contexts when defining a validation.
-
- Example:
-
- class Person
- include ActiveModel::Validations
-
- attr_reader :name
- validates_presence_of :name, on: [:verify, :approve]
- end
-
- person = Person.new
- person.valid? # => true
- person.valid?(:verify) # => false
- person.errors.full_messages_for(:name) # => ["Name can't be blank"]
- person.valid?(:approve) # => false
- person.errors.full_messages_for(:name) # => ["Name can't be blank"]
-
- *Vince Puzzella*
-
-* `attribute_changed?` now accepts a hash to check if the attribute was
- changed `:from` and/or `:to` a given value.
-
- Example:
-
- model.name_changed?(from: "Pete", to: "Ringo")
-
- *Tejas Dinkar*
-
-* Fix `has_secure_password` to honor bcrypt-ruby's cost attribute.
-
- *T.J. Schuck*
-
-* Updated the `ActiveModel::Dirty#changed_attributes` method to be indifferent between using
- symbols and strings as keys.
-
- *William Myers*
-
-* Added new API methods `reset_changes` and `changes_applied` to `ActiveModel::Dirty`
- that control changes state. Previsously you needed to update internal
- instance variables, but now API methods are available.
-
- *Bogdan Gusiev*
-
-* Fix `has_secure_password` not to trigger `password_confirmation` validations
- if no `password_confirmation` is set.
-
- *Vladimir Kiselev*
-
-* `inclusion` / `exclusion` validations with ranges will only use the faster
- `Range#cover` for numerical ranges, and the more accurate `Range#include?`
- for non-numerical ones.
-
- Fixes range validations like `:a..:f` that used to pass with values like `:be`.
- Fixes #10593.
-
- *Charles Bergeron*
-
-* Fix regression in `has_secure_password`. When a password is set, but a
- confirmation is an empty string, it would incorrectly save.
-
- *Steve Klabnik* and *Phillip Calvin*
-
-* Deprecate `Validator#setup`. This should be done manually now in the validator's constructor.
-
- *Nick Sutterer*
-
-Please check [4-0-stable](https://github.com/rails/rails/blob/4-0-stable/activemodel/CHANGELOG.md) for previous changes.
+Please check [4-1-stable](https://github.com/rails/rails/blob/4-1-stable/activemodel/CHANGELOG.md) for previous changes.
View
8 activemodel/lib/active_model/secure_password.rb
@@ -20,9 +20,9 @@ module ClassMethods
# value to the password_confirmation attribute and the validation
# will not be triggered.
#
- # You need to add bcrypt-ruby (~> 3.1.2) to Gemfile to use #has_secure_password:
+ # You need to add bcrypt (~> 3.1.7) to Gemfile to use #has_secure_password:
#
- # gem 'bcrypt-ruby', '~> 3.1.2'
+ # gem 'bcrypt', '~> 3.1.7'
#
# Example using Active Record (which automatically includes ActiveModel::SecurePassword):
#
@@ -42,13 +42,13 @@ module ClassMethods
# User.find_by(name: 'david').try(:authenticate, 'notright') # => false
# User.find_by(name: 'david').try(:authenticate, 'mUc3m00RsqyRe') # => user
def has_secure_password(options = {})
- # Load bcrypt-ruby only when has_secure_password is used.
+ # Load bcrypt gem only when has_secure_password is used.
# This is to avoid ActiveModel (and by extension the entire framework)
# being dependent on a binary library.
begin
require 'bcrypt'
rescue LoadError
- $stderr.puts "You don't have bcrypt-ruby installed in your application. Please add it to your Gemfile and run bundle install"
+ $stderr.puts "You don't have bcrypt installed in your application. Please add it to your Gemfile and run bundle install"
raise
end
View
2 activemodel/lib/active_model/version.rb
@@ -1,7 +1,7 @@
module ActiveModel
# Returns the version of the currently loaded ActiveModel as a Gem::Version
def self.version
- Gem::Version.new "4.1.0.beta2"
+ Gem::Version.new "4.2.0.alpha"
end
module VERSION #:nodoc:
View
1,864 activerecord/CHANGELOG.md
@@ -1,1858 +1,42 @@
-* Default scopes are no longer overriden by chained conditions.
+* `before_add` callbacks are fired before the record is saved on
+ `has_and_belongs_to_many` assocations *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.
- Before this change when you defined a `default_scope` in a model
- it was overriden by chained conditions in the same field. Now it
- is merged like any other scope.
+ Fixes #14144
- Before:
+* Fixed STI classes not defining an attribute method if there is a
+ conflicting private method defined on its ancestors.
- class User < ActiveRecord::Base
- default_scope { where state: 'pending' }
- scope :active, -> { where state: 'active' }
- scope :inactive, -> { where state: 'inactive' }
- end
+ Fixes #11569.
- User.all
- # SELECT "users".* FROM "users" WHERE "users"."state" = 'pending'
-
- User.active
- # SELECT "users".* FROM "users" WHERE "users"."state" = 'active'
-
- User.where(state: 'inactive')
- # SELECT "users".* FROM "users" WHERE "users"."state" = 'inactive'
-
- After:
-
- class User < ActiveRecord::Base
- default_scope { where state: 'pending' }
- scope :active, -> { where state: 'active' }
- scope :inactive, -> { where state: 'inactive' }
- end
-
- User.all
- # SELECT "users".* FROM "users" WHERE "users"."state" = 'pending'
-
- User.active
- # SELECT "users".* FROM "users" WHERE "users"."state" = 'pending' AND "users"."state" = 'active'
-
- User.where(state: 'inactive')
- # SELECT "users".* FROM "users" WHERE "users"."state" = 'pending' AND "users"."state" = 'inactive'
-
- To get the previous behavior it is needed to explicitly remove the
- `default_scope` condition using `unscoped`, `unscope`, `rewhere` or
- `except`.
-
- Example:
-
- class User < ActiveRecord::Base
- default_scope { where state: 'pending' }
- scope :active, -> { unscope(where: :state).where(state: 'active') }
- scope :inactive, -> { rewhere state: 'inactive' }
- end
-
- User.all
- # SELECT "users".* FROM "users" WHERE "users"."state" = 'pending'
-
- User.active
- # SELECT "users".* FROM "users" WHERE "users"."state" = 'active'
-
- User.inactive
- # SELECT "users".* FROM "users" WHERE "users"."state" = 'inactive'
-
-* Perform necessary deeper encoding when hstore is inside an array.
-
- Fixes #11135.
-
- *Josh Goodall*, *Genadi Samokovarov*
-
-* Properly detect if a connection is still active before using it
- in multi-threaded environments.
-
- Fixes #12867.
-
- *Kevin Casey*, *Matthew Draper*, *William (B.J.) Snow Orvis*
-
-* When inverting add_index use the index name if present instead of
- the columns.
-
- If there are two indices with matching columns and one of them is
- explicitly named then reverting the migration adding the named one
- would instead drop the unnamed one.
-
- The inversion of add_index will now drop the index by its name if
- it is present.
-
- *Hubert Dąbrowski*
-
-* Add flag to disable schema dump after migration.
-
- Add a config parameter on Active Record named `dump_schema_after_migration`
- which is true by default. Now schema dump does not happen at the
- end of migration rake task if `dump_schema_after_migration` is false.
-
- *Emil Soman*
-
-* `find_in_batches`, `find_each`, `Result#each` and `Enumerable#index_by` now
- return an `Enumerator` that can calculate its size.
-
- See also #13938.
-
- *Marc-André Lafortune*
-
-* Make sure transaction state gets reset after a commit operation on the record.
-
- If a new transaction was open inside a callback, the record was loosing track
- of the transaction level state, and it was leaking that state.
-
- Fixes #12566.
-
- *arthurnn*
-
-* Pass `has_and_belongs_to_many` `:autosave` option to
- the underlying `has_many :through` association.
-
- Fixes #13923.
-
- *Yves Senn*
-
-* PostgreSQL implementation of `SchemaStatements#index_name_exists?`.
-
- The database agnostic implementation does not detect with indexes that are
- not supported by the ActiveRecord schema dumper. For example, expressions
- indexes would not be detected.
-
- Fixes #11018.
-
- *Jonathan Baudanza*
-
-* Parsing PostgreSQL arrays with empty strings now works correctly.
-
- Previously, if you tried to parse `{"1","","2","","3"}` the result
- would be `["1","2","3"]`, removing the empty strings from the array,
- which would be incorrect. Now it will correctly produce `["1","","2","","3"]`
- as the result of parsing the above PostgreSQL array.
-
- Fixes #13907.
-
- *Maurício Linhares*
-
-* Associations now raise `ArgumentError` on name conflicts.
-
- Dangerous association names conflicts include instance or class methods already
- defined by `ActiveRecord::Base`.
-
- Example:
-
- class Car < ActiveRecord::Base
- has_many :errors
- end
- # Will raise ArgumentError.
-
- Fixes #13217.
-
- *Lauro Caetano*
-
-* Fix regressions on `select_*` methods.
- When `select_*` methods receive a `Relation` object, they should be able to
- get the arel/binds from it.
- Also fix regressions on `select_rows` that was ignoring the binds.
-
- Fixes #7538, #12017, #13731, #12056.
-
- *arthurnn*
-
-* Active Record objects can now be correctly dumped, loaded and dumped again
- without issues.
-
- Previously, if you did `YAML.dump`, `YAML.load` and then `YAML.dump` again
- in an Active Record model that used serialization it would fail at the last
- dump due to the fields not being correctly serialized before being dumped
- to YAML. Now it is possible to dump and load the same object as many times
- as needed without any issues.
-
- Fixes #13861.
-
- *Maurício Linhares*
-
-* `find_in_batches` now returns an `Enumerator` when called without a block, so that it
- can be chained with other `Enumerable` methods.
-
- *Marc-André Lafortune*
-
-* `enum` now raises on "dangerous" name conflicts.
-
- Dangerous name conflicts includes instance or class method conflicts
- with methods defined within `ActiveRecord::Base` but not its ancestors,
- as well as conflicts with methods generated by other enums on the same
- class.
-
- Fixes #13389.
-
- *Godfrey Chan*
-
-* `scope` now raises on "dangerous" name conflicts.
-
- Similar to dangerous attribute methods, a scope name conflict is
- dangerous if it conflicts with an existing class method defined within
- `ActiveRecord::Base` but not its ancestors.
-
- See also #13389.
-
- *Godfrey Chan*, *Philippe Creux*
-
-* Correctly send an user provided statement to a `lock!()` call.
-
- person.lock! 'FOR SHARE NOWAIT'
- # Before: SELECT * ... LIMIT 1 FOR UPDATE
- # After: SELECT * ... LIMIT 1 FOR SHARE NOWAIT
-
- Fixes #13788.
-
- *Maurício Linhares*
-
-* Handle aliased attributes `select()`, `order()` and `reorder()`.
-
- *Tsutomu Kuroda*
-
-* Reset the collection association when calling `reset` on it.
-
- Before:
-
- post.comments.loaded? # => true
- post.comments.reset
- post.comments.loaded? # => true
-
- After:
-
- post.comments.loaded? # => true
- post.comments.reset
- post.comments.loaded? # => false
-
- Fixes #13777.
-
- *Kelsey Schlarman*
-
-* Make enum fields work as expected with the `ActiveModel::Dirty` API.
-
- Before this change, using the dirty API would have surprising results:
-
- conversation = Conversation.new
- conversation.status = :active
- conversation.status = :archived
- conversation.status_was # => 0
-
- After this change, the same code would result in:
-
- conversation = Conversation.new
- conversation.status = :active
- conversation.status = :archived
- conversation.status_was # => "active"
-
- *Rafael Mendonça França*
-
-* `has_one` and `belongs_to` accessors don't add ORDER BY to the queries
- anymore.
-
- Since Rails 4.0, we add an ORDER BY in the `first` method to ensure
- consistent results among different database engines. But for singular
- associations this behavior is not needed since we will have one record to
- return. As this ORDER BY option can lead some performance issues we are
- removing it for singular associations accessors.
-
- Fixes #12623.
-
- *Rafael Mendonça França*
-
-* Prepend table name for column names passed to `Relation#select`.
-
- Example:
-
- Post.select(:id)
- # Before: => SELECT id FROM "posts"
- # After: => SELECT "posts"."id" FROM "posts"
-
- *Yves Senn*
-
-* Fail early with "Primary key not included in the custom select clause"
- in `find_in_batches`.
-
- Before this patch, the exception was raised after the first batch was
- yielded to the block. This means that you only get it, when you hit the
- `batch_size` treshold. This could shadow the issue in development.
-
- *Alexander Balashov*
-
-* Ensure `second` through `fifth` methods act like the `first` finder.
-
- The famous ordinal Array instance methods defined in ActiveSupport
- (`first`, `second`, `third`, `fourth`, and `fifth`) are now available as
- full-fledged finders in ActiveRecord. The biggest benefit of this is ordering
- of the records returned now defaults to the table's primary key in ascending order.
-
- Fixes #13743.
-
- Example:
-
- User.all.second
-
- # Before
- # => 'SELECT "users".* FROM "users"'
-
- # After
- # => SELECT "users".* FROM "users" ORDER BY "users"."id" ASC LIMIT 1 OFFSET 1'
-
- User.offset(3).second
-
- # Before
- # => 'SELECT "users".* FROM "users" LIMIT -1 OFFSET 3' # sqlite3 gem
- # => 'SELECT "users".* FROM "users" OFFSET 3' # pg gem
- # => 'SELECT `users`.* FROM `users` LIMIT 18446744073709551615 OFFSET 3' # mysql2 gem
-
- # After
- # => SELECT "users".* FROM "users" ORDER BY "users"."id" ASC LIMIT 1 OFFSET 4'
-
- *Jason Meller*
-
-* ActiveRecord states are now correctly restored after a rollback for
- models that did not define any transactional callbacks (i.e.
- `after_commit`, `after_rollback` or `after_create`).
-
- Fixes #13744.
-
- *Godfrey Chan*
-
-* Make `touch` fire the `after_commit` and `after_rollback` callbacks.
-
- *Harry Brundage*
-
-* Enable partial indexes for `sqlite >= 3.8.0`.
-
- See http://www.sqlite.org/partialindex.html
-
- *Cody Cutrer*
-
-* Don't try to get the subclass if the inheritance column doesn't exist
-
- The `subclass_from_attrs` method is called even if the column specified by
- the `inheritance_column` setting doesn't exist. This prevents setting associations
- via the attributes hash if the association name clashes with the value of the setting,
- typically `:type`. This worked previously in Rails 3.2.
-
- *Ujjwal Thaakar*
-
-* Enum mappings are now exposed via class methods instead of constants.
-
- Example:
-
- class Conversation < ActiveRecord::Base
- enum status: [ :active, :archived ]
- end
-
- Before:
-
- Conversation::STATUS # => { "active" => 0, "archived" => 1 }
-
- After:
-
- Conversation.statuses # => { "active" => 0, "archived" => 1 }
-
- *Godfrey Chan*
-
-* Set `NameError#name` when STI-class-lookup fails.
-
- *Chulki Lee*
-
-* Fix bug in `becomes!` when changing from the base model to a STI sub-class.
-
- Fixes #13272.
-
- *the-web-dev*, *Yves Senn*
-
-* Currently Active Record can be configured via the environment variable
- `DATABASE_URL` or by manually injecting a hash of values which is what Rails does,
- reading in `database.yml` and setting Active Record appropriately. Active Record
- expects to be able to use `DATABASE_URL` without the use of Rails, and we cannot
- rip out this functionality without deprecating. This presents a problem though
- when both config is set, and a `DATABASE_URL` is present. Currently the
- `DATABASE_URL` should "win" and none of the values in `database.yml` are
- used. This is somewhat unexpected, if one were to set values such as
- `pool` in the `production:` group of `database.yml` they are ignored.
-
- There are many ways that Active Record initiates a connection today:
-
- - Stand Alone (without rails)
- - `rake db:<tasks>`
- - `ActiveRecord.establish_connection`
-
- - With Rails
- - `rake db:<tasks>`
- - `rails <server> | <console>`
- - `rails dbconsole`
-
- Now all of these behave exactly the same way. The best way to do
- this is to put all of this logic in one place so it is guaranteed to be used.
-
- Here is the matrix of how this behavior works:
-
- ```
- No database.yml
- No DATABASE_URL
- => Error
- ```
-
- ```
- database.yml present
- No DATABASE_URL
- => Use database.yml configuration
- ```
-
- ```
- No database.yml
- DATABASE_URL present
- => use DATABASE_URL configuration
- ```
-
- ```
- database.yml present
- DATABASE_URL present
- => Merged into `url` sub key. If both specify `url` sub key, the `database.yml` `url`
- sub key "wins". If other paramaters `adapter` or `database` are specified in YAML,
- they are discarded as the `url` sub key "wins".
- ```
-
- Current implementation uses `ActiveRecord::Base.configurations` to resolve and merge
- all connection information before returning. This is achieved through a utility
- class: `ActiveRecord::ConnectionHandling::MergeAndResolveDefaultUrlConfig`.
-
- To understand the exact behavior of this class, it is best to review the
- behavior in `activerecord/test/cases/connection_adapters/connection_handler_test.rb`.
-
- *Richard Schneeman*
-
-* Make `change_column_null` revertable. Fixes #13576.
-
- *Yves Senn*, *Nishant Modak*, *Prathamesh Sonpatki*
-
-* Don't create/drop the test database if RAILS_ENV is specified explicitly.
-
- Previously, when the environment was development, we would always
- create or drop both the test and development databases.
-
- Now, if RAILS_ENV is explicitly defined as development, we don't create
- the test database.
-
- *Damien Mathieu*
-
-* Initialize version on Migration objects so that it can be used in a migration,
- and it will be included in the announce message.
-
- *Dylan Thacker-Smith*
-
-* `change_table` now uses the current adapter's `update_table_definition`
- method to retrieve a specific table definition.
- This ensures that `change_table` and `create_table` will use
- similar objects.
-
- Fixes #13577, #13503.
-
- *Nishant Modak*, *Prathamesh Sonpatki*, *Rafael Mendonça França*
-
-* Fixed ActiveRecord::Store nil conversion TypeError when using YAML coder.
- In case the YAML passed as paramter is nil, uses an empty string.
-
- Fixes #13570.
-