def resource_params
      attributes    = find_in_params(:attributes).try(:permit, permitted_attributes) || {}
      relationships = {}
      
      # Build Relationships Data
      relationships_in_payload = find_in_params(:relationships)
      if relationships_in_payload
        raw_relationships = relationships_in_payload.clone

        raw_relationships.each_key do |key|
          data = raw_relationships.delete(key)[:data]
        
          if permitted_relationships.include?(key.to_sym) && data
            if data.kind_of?(Array)
              relationships["#{key.singularize}_ids"] = extract_ids data
            else
              relationships["#{key}_id"] = extract_id data
            end
          end
        end
      end
      
      attributes.merge relationships
    end
def resource_params
      attributes    = find_in_params(:attributes).try(:permit, permitted_attributes) || {}
      relationships = {}
      
      # Build Relationships Data
      relationships_in_payload = find_in_params(:relationships)
      if relationships_in_payload
        raw_relationships = relationships_in_payload.clone

        raw_relationships.each_key do |key|
          data = raw_relationships.delete(key)[:data]
        
          if permitted_relationships.include?(key.to_sym) && data
            if data.kind_of?(Array)
              relationships["#{key.singularize}_ids"] = extract_ids data
            else
              relationships["#{key}_id"] = extract_id data
            end
          end
        end
      end
      
      attributes.merge relationships
    end
Builds a whitelisted resource_params hash from the permitted_attributes &
 permitted_relationships arrays.  Will automatically attempt to resolve
 string IDs to numerical IDs, in the case the model's slug was passed to
 the controller as ID.