Method: Effective::Resources::Attributes#table_attributes
- Defined in:
- app/models/effective/resources/attributes.rb
#table_attributes ⇒ Object
All table attributes. includes primary_key and belongs_tos
76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'app/models/effective/resources/attributes.rb', line 76 def table_attributes attributes = (klass.new().attributes rescue nil) return {} unless attributes (attributes.keys - [klass.primary_key]).inject({}) do |h, name| if klass.respond_to?(:column_for_attribute) # Rails 4+ column = klass.column_for_attribute(name) h[name.to_sym] = [column.type] if column.table_name # Rails 5 attributes API else h[name.to_sym] = [klass.columns_hash[name].type] end; h end end |