Method: ActiveRecord::SpawnMethods#except

Defined in:
lib/active_record/relation/spawn_methods.rb

#except(*skips) ⇒ Object

Removes from the query the condition(s) specified in skips.

Example:

Post.order('id asc').except(:order)                  # discards the order condition
Post.where('id > 10').order('id asc').except(:where) # discards the where condition but keeps the order


82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/active_record/relation/spawn_methods.rb', line 82

def except(*skips)
  result = self.class.new(@klass, table)
  result.default_scoped = default_scoped

  ((Relation::ASSOCIATION_METHODS + Relation::MULTI_VALUE_METHODS) - skips).each do |method|
    result.send(:"#{method}_values=", send(:"#{method}_values"))
  end

  (Relation::SINGLE_VALUE_METHODS - skips).each do |method|
    result.send(:"#{method}_value=", send(:"#{method}_value"))
  end

  # Apply scope extension modules
  result.send(:apply_modules, extensions)

  result
end