summaryrefslogtreecommitdiffstats
path: root/config/initializers/10-patches.rb
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2017-07-23 11:26:04 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2017-07-23 11:26:04 +0000
commitd74f0bfd5c53962e332c2dd4d30dafaa1105b92b (patch)
treef3eaf66d67c3a87fb34340561bf188d364de623c /config/initializers/10-patches.rb
parent41bb302594b48152b87c92f196c915f499093bbf (diff)
downloadredmine-d74f0bfd5c53962e332c2dd4d30dafaa1105b92b.tar.gz
redmine-d74f0bfd5c53962e332c2dd4d30dafaa1105b92b.zip
Merged rails-5.1 branch (#23630).
git-svn-id: http://svn.redmine.org/redmine/trunk@16859 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'config/initializers/10-patches.rb')
-rw-r--r--config/initializers/10-patches.rb28
1 files changed, 26 insertions, 2 deletions
diff --git a/config/initializers/10-patches.rb b/config/initializers/10-patches.rb
index 2693f83f4..13efe0cb5 100644
--- a/config/initializers/10-patches.rb
+++ b/config/initializers/10-patches.rb
@@ -27,6 +27,30 @@ module ActiveRecord
end
end
class Relation ; undef open ; end
+
+ # Workaround for a Rails 5.1 regression that breaks queries with a condition
+ # on a table that has a column with the same name as the table
+ # (eg. comments.comments). It breaks has_many associations to these tables as well.
+ # https://github.com/rails/rails/commit/c6a62dc327c54baec87306f5c381e13cacc00a19
+ #
+ # Examples (without the following workaround applied):
+ # Comment.where(:comments => {:id => 1})
+ # TypeError: can't cast Hash
+ #
+ # News.first.comments.count
+ # TypeError: can't cast Hash
+ class PredicateBuilder
+
+ protected
+ alias :create_binds_for_hash_without_comments_fix :create_binds_for_hash
+ def create_binds_for_hash(attributes)
+ if attributes["comments"].is_a?(Hash)
+ return create_binds_for_hash_without_comments_fix attributes["comments"]
+ else
+ create_binds_for_hash_without_comments_fix attributes
+ end
+ end
+ end
end
module ActionView
@@ -201,7 +225,7 @@ module ActionView
unless asset_id.blank?
source += "?#{asset_id}"
end
- asset_path(source, options)
+ asset_path(source, options.merge(skip_pipeline: true))
end
alias :path_to_asset :asset_path_with_asset_id
@@ -218,7 +242,7 @@ module ActionView
if File.exist? path
exist = true
else
- path = File.join(Rails.public_path, compute_asset_path("#{source}#{extname}", options))
+ path = File.join(Rails.public_path, public_compute_asset_path("#{source}#{extname}", options))
if File.exist? path
exist = true
end