内部错误500 jbuilder [英] Internal Error 500 jbuilder
本文介绍了内部错误500 jbuilder的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用jbuilder在我的Rails应用中渲染一些json,但是输出显示为:
I'm trying to render some json in my rails app using jbuilder, but the output is showing up as:
{"status":"500","error":"Internal Server Error"}
以下是网址:
http://localhost:3000/api/v1/appusers/10
这里是控制器:
module Api
module V1
class AppusersController < ApplicationController
respond_to :json
skip_before_action :verify_authenticity_token
def show
@appuser = Appuser.find(params[:id])
end
还有我的show.json.jbuilder文件:
And my show.json.jbuilder file:
json.extract! @appuser, :user_auth_token, :id
end
我以前从未在jbuilder上遇到过这个问题,我所有其他jbuilder文件都可以正常工作.知道我想念的是什么吗?
I've never encountered this before with jbuilder and all of my other jbuilder files work just fine. Any idea what I'm missing?
推荐答案
根据文档,您不需要jbuilder
模板中的end
,只需:
According to documentation, you don't need the end
in the jbuilder
template, just:
json.extract! @appuser, :user_auth_token, :id
或者,如果您使用的是低于1.9的Ruby
版本,则可以使用以下语法:
Alternatively, if you are using a Ruby
version major than 1.9, you can use this syntax:
json.(@appuser, :user_auth_token, :id)
这篇关于内部错误500 jbuilder的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文