Method: Administrate::Field::HasMany.permitted_attribute
- Defined in:
- lib/administrate/field/has_many.rb
.permitted_attribute(attr, _options = {}) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/administrate/field/has_many.rb', line 10 def self.permitted_attribute(attr, = {}) # This may seem arbitrary, and improvable by using reflection. # Worry not: here we do exactly what Rails does. Regardless of the name # of the foreign key, has_many associations use the suffix `_ids` # for this. # # Eg: if the associated table and primary key are `countries.code`, # you may expect `country_codes` as attribute here, but it will # be `country_ids` instead. # # See https://github.com/rails/rails/blob/b30a23f53b52e59d31358f7b80385ee5c2ba3afe/activerecord/lib/active_record/associations/builder/collection_association.rb#L48 {"#{attr.to_s.singularize}_ids": []} end |