Fixes regression in #18423. Merge default headers for new responses,
but don't merge when creating a response from the last session request.
hat tip @senny ❤️
`validates_uniqueness_of` would blow up when used with a scope that was
an array column. The validator must perform a query to determine whether
the record already exists in the database, and uses the scope to do so.
When it constructs the query, it deserializes the value of the scope (an
array). Unfortunately this breaks the query because Postgres is still
expecting that value to be an array. There is a newer version of Arel
that prevents this from happening, but 4.1 is not on that version, so we
have to emulate that code here.
`coder.represent_scalar` means something along the lines of "Here is a quoted
string, you can just add it to the output", which is not the case here. It only
works for simple strings that can appear unquoted in YAML, but causes problems
for e.g. primitive-like strings ("1", "true").
`coder.represent_object` on the other hand, means that "This is the Ruby-object
representation for this thing suitable for use in YAML dumping", which is what
we want here.
Before:
YAML.load ActiveSupport::SafeBuffer.new("Hello").to_yaml # => "Hello"
YAML.load ActiveSupport::SafeBuffer.new("true").to_yaml # => true
YAML.load ActiveSupport::SafeBuffer.new("false").to_yaml # => false
YAML.load ActiveSupport::SafeBuffer.new("1").to_yaml # => 1
YAML.load ActiveSupport::SafeBuffer.new("1.1").to_yaml # => 1.1
After:
YAML.load ActiveSupport::SafeBuffer.new("Hello").to_yaml # => "Hello"
YAML.load ActiveSupport::SafeBuffer.new("true").to_yaml # => "true"
YAML.load ActiveSupport::SafeBuffer.new("false").to_yaml # => "false"
YAML.load ActiveSupport::SafeBuffer.new("1").to_yaml # => "1"
YAML.load ActiveSupport::SafeBuffer.new("1.1").to_yaml # => "1.1"
If we ever want Ruby to behave more like PHP or JavaScript though, this is an
excellent trick to use ;)
Conflicts:
activesupport/CHANGELOG.md
Thor isn't very discerning over whether some content is present when passed
to `inject_into_file`, e.g. a commented out route is detected as being present.
So to prevent people scratching their heads as to why a route hasn't appeared
it's better to fall on the side of having duplicate routes.
(cherry picked from commit 80838d9bd5)
When there is a single scaffold in the routes.rb with no other lines
then revoking/destroying it will create a routes.rb file with a syntax
error. This is because the sentinel for the Thor `route` action didn't
include the newline but the logged route code did.
The fix is to add the newline to the sentinel and remove it from the
the logged route code.
Fixes#15913.
(cherry picked from commit 1c59ffca5c)
Conflicts:
railties/CHANGELOG.md
While we query the proper columns, we go through normal handling for
converting the value to a primitive which assumes it should use the
table's primary key. If the association specifies a different value (and
we know that we're working with an association), we should use the
custom primary key instead.
Fixes#18813.
Conflicts:
activerecord/lib/active_record/relation/predicate_builder/association_query_handler.rb
activerecord/lib/active_record/table_metadata.rb
Fixes an issue that would cause the format set in default_url_options to be lost
when generating URLs with fewer positional arguments than parameters in the
route definition.
This is a backport of #18627 that only fixes the issue for :format so as not to
break existing behaviour.
Fixed AR::Relation#group method when argument is a SQL reserved keyword
Conflicts:
activerecord/CHANGELOG.md
activerecord/lib/active_record/relation/query_methods.rb
Also sync Russian Federation time zones with `zone.tab` file from tzdata version 2014j.
(cherry picked from commit f996dcf7ef)
Conflicts:
activesupport/CHANGELOG.md
fix for messages in invalid encoding from db-drivers
Conflicts:
activerecord/lib/active_record/connection_adapters/abstract_adapter.rb
activerecord/test/cases/connection_adapters/abstract_adapter_test.rb
Add setting of FK for throgh associations while building
Conflicts:
activerecord/CHANGELOG.md
activerecord/test/cases/associations/has_many_through_associations_test.rb
Conflicts:
activerecord/CHANGELOG.md