Merge pull request #748 from raphaelpereira/0-9-stable

Propagate serialization_options across associations
This commit is contained in:
Alexandre de Oliveira
2015-03-30 16:31:41 -03:00
4 changed files with 21 additions and 6 deletions

View File

@@ -109,6 +109,13 @@ end
class PostSerializer < ActiveModel::Serializer
attributes :title, :body
def title
keyword = serialization_options[:highlight_keyword]
title = object.read_attribute_for_serialization(:title)
title = title.gsub(keyword,"'#{keyword}'") if keyword
title
end
has_many :comments
end