active model serializer with virtual attribute - Rails 4
问题 I am currently making API with RoR, and I need to create an object with virtual attributes and associated object. The problem is that serializer does not kick in when I return an object with virtual attribute. Here is the returned object from foo_controller { :id=>280, :virtual=>"y8st07ef7u" :user_id=>280 } :virtual is a virtual attribute and user_id is an id of associated table - User. My goal is to make this { :id=>280, :virtual=>"y8st07ef7u", :user=>{ :id=>280, :name=>'foo' } } Foo