class CmAdmin::ResourceController

def attachment_fields(model_object)

def attachment_fields(model_object)
  model_object.reflect_on_all_associations.map do |reflection|
    next if reflection.options[:polymorphic]
    if reflection.class.name.include?('HasOne')
      reflection.name.to_s.gsub('_attachment', '').gsub('rich_text_', '').to_sym
    elsif reflection.class.name.include?('HasMany')
      Hash[reflection.name.to_s.gsub('_attachments', ''), []]
    end
  end.compact
end