
Untitled
By: a guest on
May 2nd, 2012 | syntax:
None | size: 0.63 KB | hits: 10 | expires: Never
class << ActiveRecord::Base
# Model.find(:all, :except => 'body')
# except is a comma delimted list of fields to exclude from db queries
def find_with_except(*args)
options = args.extract_options!
raise ArgumentError, "can't pass both :select and :except" if options[:except] && options[:select]
if options[:except]
formated_options = Array(options.delete(:except)).map!(&:to_s)
options[:select] = (Article.column_names - formated_options).join(", ")
find_without_except(*(args << options))
else
find_without_except(*(args << options))
end
end
alias_method_chain :find, :except
end