lib/formtastic/inputs/base/collections.rb in formtastic-2.3.1 vs lib/formtastic/inputs/base/collections.rb in formtastic-3.0.0.rc

- old
+ new

@@ -76,31 +76,19 @@ raise PolymorphicInputWithoutCollectionError.new( "A collection must be supplied for #{method} input. Collections cannot be guessed for polymorphic associations." ) if reflection.options[:polymorphic] == true end - find_options_from_options = options[:find_options] || {} - conditions_from_options = find_options_from_options[:conditions] || {} conditions_from_reflection = (reflection.respond_to?(:options) && reflection.options[:conditions]) || {} conditions_from_reflection = conditions_from_reflection.call if conditions_from_reflection.is_a?(Proc) scope_conditions = conditions_from_reflection.empty? ? nil : {:conditions => conditions_from_reflection} - if conditions_from_options.any? - if Util.rails3? - reflection.klass.scoped(scope_conditions).where(conditions_from_options) - else - reflection.klass.where(scope_conditions[:conditions]).where(conditions_from_options) - end + where_conditions = (scope_conditions && scope_conditions[:conditions]) || {} + + if Util.rails3? + reflection.klass.scoped(scope_conditions).where({}) # where is uneccessary, but keeps the stubbing simpler while we support rails3 else - - if Util.rails3? - find_options_from_options.merge!(:include => group_by) if self.respond_to?(:group_by) && group_by - reflection.klass.scoped(scope_conditions).where(find_options_from_options) - else - coll = reflection.klass.where(scope_conditions) - coll = coll.includes(group_by) if self.respond_to?(:group_by) && group_by - coll.where(find_options_from_options) - end + reflection.klass.where(where_conditions) end end end def collection_for_boolean