Module: JsonApiToolbox::Postable
- Defined in:
- lib/postable.rb
Class Method Summary collapse
Class Method Details
.normalize_post(hash, model) ⇒ Object
6 7 8 9 10 11 12 13 14 15 |
# File 'lib/postable.rb', line 6 def normalize_post(hash, model) associations = model.reflect_on_all_associations.map(&:name) normalized_hash = hash.map do |key, value| child_model = association_class(model, key) if value.is_a? Hash key = "#{key}_attributes" if associations.include?(key.to_sym) hash_value = check_child_association(value, key, model, child_model) [key, hash_value] end normalized_hash.to_h end |