From 63465fda6870d9adbbdde4639b41188e9d6e7478 Mon Sep 17 00:00:00 2001 From: Ray Cohen Date: Sat, 28 Jul 2012 13:01:06 -0400 Subject: [PATCH] fix custom attributes with scope readme section --- README.md | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index a0cd0792..aeb19a39 100644 --- a/README.md +++ b/README.md @@ -222,10 +222,14 @@ class Person < ActiveRecord::Base def full_name "#{first_name} #{last_name}" end - +end + +class PersonSerializer < ActiveModel::Serializer + attributes :first_name, :last_name + def attributes - hash = super(options) - hash["full_name"] = full_name if scope.admin? + hash = super + hash["full_name"] = object.full_name if scope.admin? hash end end