ActiveModel :: ArraySerializer和Doorkeeper gem交互

时间:2013-11-19 14:32:19

标签: ruby-on-rails json mongoid active-model-serializers doorkeeper

所以我正在尝试使用rails 4和ruby 2.0.0 ActiveModelSerializer gem(0.8.1)和Doorkeeper gem(实际上是fork(https://github.com/simonbnrd/doorkeeper)来构建rails API应用程序,以便将此游戏与mongoid 4一起使用,但我认为不是这样的。当我启动我的应用程序并使用ActiveModel :: ArraySerializer创建新对象,然后尝试将其呈现为json - 一切正常。但是如果我在调用方法之后做出相同的动作序列(来自门卫宝石)门卫:: TokensController.create渲染到json应用程序突然返回字符串。试图调查此问题我找不到to_json方法的源代码位置。

def index
 @users = User.all
 a = ActiveModel::ArraySerializer.new(@users)
 raise a.class.method(:to_json).source_location.inspect
 render json: @users
end

返回

gems/activesupport-4.0.1/lib/active_support/core_ext/object/to_json.rb
在门卫呼叫之前

nil

0 个答案:

没有答案