提交 f224b4f0 编写于 作者: A Angelo Capilleri

small refactoring of build_relation in uniqueness

reflection init as 'if' stantment.
column is always the same expression and depends from the changing of attributes
上级 f655108c
......@@ -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.
先完成此消息的编辑!
想要评论请 注册