The ignored_columns
attribute allows the exclusion of certain columns when
working with ActiveRecord models in Rails. However, accessing an ignored
column from an ActiveRecord model wail raise a NoMethodError
.
Columns are added to ignored_columns
when they need to be deprecated in the near future, this is the first
step recommended before removing a column from a model. Hence, accessing ignored_columns
should be avoided.
class User < ApplicationRecord
self.ignored_columns = [:email]
end
User.find_by(email: '[email protected]') # This will raise a NoMethodError
class User < ApplicationRecord
self.ignored_columns = [:email]
end
User.find_by(name: 'John Appleseed') # This will not raise any error