rails gemのactive_model_serializerに関する質問です。
attributeのoptionとしてifを入れているのですが、機能していません。原因がわかる方いらっしゃいますでしょうか??
ruby
1class HogeSerializer < ActiveModel::Serializer 2 self.root = false 3 4 attribute :test, if: :is_current_user? 5 6 def is_current_user? 7 byebug 8 1 == 2 9 end 10 11 def test 12 'OK' 13 end 14end 15
現在このようにしていますが、byebugのところに来ません。
また、response.bodyも
ruby
1(byebug) response.body 2 {"test : "OK"}
となっています。
よろしくお願いします・
あなたの回答
tips
プレビュー