Files
openfoodnetwork/app/serializers/api/admin/customer_serializer.rb
Maikel Linke fa5fa9e228 Auto-complete tags on customers page
- new controller serving tags for an enterprise as JSON
- customers page suggesting these tags
- emphasising tags that have rules
2016-04-29 15:18:17 +10:00

16 lines
352 B
Ruby

class Api::Admin::CustomerSerializer < ActiveModel::Serializer
attributes :id, :email, :enterprise_id, :user_id, :code, :tags, :tag_list
def tag_list
object.tag_list.join(",")
end
def tags
tag_rule_map = object.enterprise.rules_per_tag
object.tag_list.map do |tag|
{ text: tag, rules: tag_rule_map[tag] }
end
end
end