summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorblackst0ne <blackst0ne.ru@gmail.com>2018-04-06 12:31:44 +1100
committerblackst0ne <blackst0ne.ru@gmail.com>2018-04-06 12:31:44 +1100
commitcfa716d6fe90802a05b5e130a271f404001c7916 (patch)
treed62926fb0802cde06f25338a21ab9325ac35e205
parent774f065e4e9452748cc8dcf12cc228fae5ae8bd8 (diff)
downloadgitlab-ce-cfa716d6fe90802a05b5e130a271f404001c7916.tar.gz
Fix sha_attribute
-rw-r--r--lib/gitlab/database/sha_attribute.rb22
1 files changed, 8 insertions, 14 deletions
diff --git a/lib/gitlab/database/sha_attribute.rb b/lib/gitlab/database/sha_attribute.rb
index 882e31e711f..a658bb8928b 100644
--- a/lib/gitlab/database/sha_attribute.rb
+++ b/lib/gitlab/database/sha_attribute.rb
@@ -6,7 +6,14 @@ module Gitlab
# behaviour from the default Binary type.
ActiveRecord::ConnectionAdapters::PostgreSQL::OID::Bytea
else
- type_binary
+ # In Rails 5.0 `Type` has been moved from `ActiveRecord` to `ActiveModel`
+ # https://github.com/rails/rails/commit/9cc8c6f3730df3d94c81a55be9ee1b7b4ffd29f6#diff-f8ba7983a51d687976e115adcd95822b
+ # Remove this method and leave just `ActiveModel::Type::Binary` when upgraded to rails 5.0
+ if Gitlab.rails5?
+ ActiveModel::Type::Binary
+ else
+ ActiveRecord::Type::Binary
+ end
end
# Class for casting binary data to hexadecimal SHA1 hashes (and vice-versa).
@@ -46,18 +53,5 @@ module Gitlab
Gitlab.rails5? ? super(arg) : type_cast_for_database(arg)
end
end
-
- private
-
- # In Rails 5.0 `Type` has been moved from `ActiveRecord` to `ActiveModel`
- # https://github.com/rails/rails/commit/9cc8c6f3730df3d94c81a55be9ee1b7b4ffd29f6#diff-f8ba7983a51d687976e115adcd95822b
- # Remove this method and leave just `ActiveModel::Type::Binary` when upgraded to rails 5.0
- def type_binary
- if Gitlab.rails5?
- ActiveModel::Type::Binary
- else
- ActiveRecord::Type::Binary
- end
- end
end
end