From 81fddb55d3ff3517a01d5fa195f402b91e051045 Mon Sep 17 00:00:00 2001 From: vanstee Date: Wed, 16 May 2012 22:47:52 -0400 Subject: [PATCH] Remove left over references to scope instance variable --- README.markdown | 4 ++-- lib/active_model/serializer.rb | 2 +- test/serializer_test.rb | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/README.markdown b/README.markdown index 07cde73b..6bed51f5 100644 --- a/README.markdown +++ b/README.markdown @@ -126,12 +126,12 @@ class PostSerializer < ActiveModel::Serializer # only let the user see comments he created. def comments - post.comments.where(:created_by => @scope) + post.comments.where(:created_by => options[:scope]) end end ``` -In a serializer, `@scope` is the current authorization scope (usually +In a serializer, `options[:scope]` is the current authorization scope (usually `current_user`), which the controller gives to the serializer when you call `render :json` diff --git a/lib/active_model/serializer.rb b/lib/active_model/serializer.rb index 5aef7812..55d303e0 100644 --- a/lib/active_model/serializer.rb +++ b/lib/active_model/serializer.rb @@ -91,7 +91,7 @@ module ActiveModel # end # # def author? - # post.author == scope + # post.author == options[:scope] # end # end # diff --git a/test/serializer_test.rb b/test/serializer_test.rb index 8d31d8dc..61895379 100644 --- a/test/serializer_test.rb +++ b/test/serializer_test.rb @@ -71,8 +71,8 @@ class SerializerTest < ActiveModel::TestCase end class CommentSerializer - def initialize(comment, scope, options={}) - @comment, @scope = comment, scope + def initialize(comment, options={}) + @comment = comment end def serializable_hash