You cannot do this using scope:
IGNORED = %w( id created_at updated_at ) scope :filtered, lambda { select( cols ) } def self.cols attribute_names = [] attributes = self.columns.reject { |c| IGNORED.include?( c.name ) } attributes.each { |attr| attribute_names << attr.name } attribute_names end Model.filtered [#<Model name: "Test 2", reg_num: "KA 02", description: "aldsfjadflkj">]
source share