mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-25 15:23:06 +00:00
Merge pull request #748 from raphaelpereira/0-9-stable
Propagate serialization_options across associations
This commit is contained in:
7
test/fixtures/poro.rb
vendored
7
test/fixtures/poro.rb
vendored
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user