From bbe3ac582c0e7d0a2312613035b0370af99137d1 Mon Sep 17 00:00:00 2001 From: Matt Jones Date: Wed, 21 Sep 2011 15:29:55 -0400 Subject: [PATCH] [#700] complain about useless :unique => true declaration --- hobo_fields/lib/hobo_fields/model.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/hobo_fields/lib/hobo_fields/model.rb b/hobo_fields/lib/hobo_fields/model.rb index 189f71d95..aaba80976 100644 --- a/hobo_fields/lib/hobo_fields/model.rb +++ b/hobo_fields/lib/hobo_fields/model.rb @@ -170,7 +170,11 @@ def self.add_formatting_for_field(name, type, args) def self.add_index_for_field(name, args, options) to_name = options.delete(:index) - return unless to_name + unless to_name + # passing :unique => true doesn't do anything without an index + Rails.logger.error('ERROR: passing :unique => true without :index => true does nothing. Use :unique instead.') if options[:unique] + return + end index_opts = {} index_opts[:unique] = :unique.in?(args) || options.delete(:unique) # support :index => true declaration