the index option is always created if the type is one of references or belongs_to. Refactoring it to a simpler form and fixing the build

This commit is contained in:
Vijay Dev 2012-04-18 02:16:44 +05:30
parent 3b0ffb1efd
commit 938464d475
1 changed files with 4 additions and 2 deletions

View File

@ -22,8 +22,10 @@ module Rails
type, attr_options = *parse_type_and_options(type)
references_index = type.in?(%w(references belongs_to)) && UNIQ_INDEX_OPTIONS.include?(has_index) ? {:unique => true} : true
attr_options.merge!({:index => references_index}) if references_index
if type.in?(%w(references belongs_to))
references_index = UNIQ_INDEX_OPTIONS.include?(has_index) ? {:unique => true} : true
attr_options.merge!({:index => references_index})
end
new(name, type, has_index, attr_options)
end