---
title: "Rails 5 adds ignored_columns for Active Record"
description: "Rails 5 has implemented ignored_columns method for active record."
canonical_url: "https://www.bigbinary.com/blog/rails-5-adds-active-record-ignored-columns"
markdown_url: "https://www.bigbinary.com/blog/rails-5-adds-active-record-ignored-columns.md"
---

# Rails 5 adds ignored_columns for Active Record

Rails 5 has implemented ignored_columns method for active record.

- Author: Hitesh Rawal
- Published: May 24, 2016
- Categories: Rails 5, Rails

Sometimes we need to ignore a database column. However Rails 4.x doesn't have
any officially defined method which ignores a database column from Active
Record. We can apply our patch on model to ignore certain columns.

```ruby
class User < ActiveRecord::Base

  # Ignoring employee_email column
  def self.columns
    super.reject {|column| column.name == 'employee_email'}
  end

end
```

### Rails 5 added ignored_columns

Rails 5 [has added ignored_columns](https://github.com/rails/rails/pull/21720)
to `ActiveRecord::Base` class.

Here is revised code after using `ignored_columns` method.

```ruby
class User < ApplicationRecord
  self.ignored_columns = %w(employee_email)
end
```

## Links

- [Human page](https://www.bigbinary.com/blog/rails-5-adds-active-record-ignored-columns)
