提交 15712ac4 编写于 作者: R Rafael Mendonça França

Merge pull request #7791 from acapilleri/build_association

small refactoring of build_relation in uniqueness
......@@ -64,14 +64,12 @@ def find_finder_class_for(record) #:nodoc:
end
def build_relation(klass, table, attribute, value) #:nodoc:
reflection = klass.reflect_on_association(attribute)
if reflection
column = klass.columns_hash[reflection.foreign_key]
if reflection = klass.reflect_on_association(attribute)
attribute = reflection.foreign_key
value = value.attributes[reflection.primary_key_column.name]
else
column = klass.columns_hash[attribute.to_s]
end
column = klass.columns_hash[attribute.to_s]
value = column.limit ? value.to_s[0, column.limit] : value.to_s if !value.nil? && column.text?
if !options[:case_sensitive] && value && column.text?
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册