diff options
author | Sean Griffin <sean@seantheprogrammer.com> | 2015-09-24 09:08:43 -0600 |
---|---|---|
committer | Sean Griffin <sean@seantheprogrammer.com> | 2015-09-24 09:08:43 -0600 |
commit | 8587cf0d930832c362249ccec5fe896bd6563e2b (patch) | |
tree | 298ca6c3f0a593cb55f9fe90c4f69b7647d43e94 /activerecord/lib/active_record | |
parent | 4a375a83deab7a3089e718a1d18ddc4c2846cd40 (diff) | |
parent | 4ccdd4122dfdab200c02f78a994f4112d6164164 (diff) | |
download | rails-8587cf0d930832c362249ccec5fe896bd6563e2b.tar.gz rails-8587cf0d930832c362249ccec5fe896bd6563e2b.tar.bz2 rails-8587cf0d930832c362249ccec5fe896bd6563e2b.zip |
Merge pull request #21720 from byroot/ignore-columns
Implement ActiveRecord::Base.ignored_columns
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r-- | activerecord/lib/active_record/model_schema.rb | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/model_schema.rb b/activerecord/lib/active_record/model_schema.rb index c461c04a26..a9bd094a66 100644 --- a/activerecord/lib/active_record/model_schema.rb +++ b/activerecord/lib/active_record/model_schema.rb @@ -50,6 +50,13 @@ module ActiveRecord class_attribute :pluralize_table_names, instance_writer: false self.pluralize_table_names = true + ## + # :singleton-method: + # Accessor for the list of columns names the model should ignore. Ignored columns won't have attribute + # accessors defined, and won't be referenced in SQL queries. + class_attribute :ignored_columns, instance_accessor: false + self.ignored_columns = [].freeze + self.inheritance_column = 'type' delegate :type_for_attribute, to: :class @@ -308,7 +315,7 @@ module ActiveRecord end def load_schema! - @columns_hash = connection.schema_cache.columns_hash(table_name) + @columns_hash = connection.schema_cache.columns_hash(table_name).except(*ignored_columns) @columns_hash.each do |name, column| warn_if_deprecated_type(column) define_attribute( |