blob: ac258325edde67be50dd488787caded99cbbc1a4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
class PhoneBookEntrySerializer < ActiveModel::Serializer
embed :ids, :include => true
attributes :id, :first_name, :last_name, :organization, :search_result_display
has_many :phone_numbers
def search_result_display
result = "#{object.last_name}, #{object.first_name}".strip.gsub(/^, /,'').gsub(/,$/,'')
if result.blank?
result = "#{object.organization}"
end
return result
end
end
|