Ignore columns on ActiveRecord queries in Rails
ActiveRecord models have
ignored_columns defined as a class attribute. This allows us to, just like it says, ignore a particular column from our queries and returning ActiveRecords.
class Procedure < ApplicationRecord self.ignored_columns = [:created_at, :updated_at] end
If we perform a lookup, this is what we'll now see.
Procedure.all => SELECT "procedures"."id", "procedures"."name" FROM "procedures"
Notice the subtle difference?
ignored_columns declaration, we'd see a query like this:
Procedure.all => SELECT "procedures".* FROM "procedures"