Internal Error 500 jbuilder

匆匆过客 提交于 2019-12-11 07:15:39

问题


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"}

Here's the url:

http://localhost:3000/api/v1/appusers/10

Here's the controller:

module Api
  module V1
    class AppusersController < ApplicationController
      respond_to :json
      skip_before_action :verify_authenticity_token

      def show
        @appuser = Appuser.find(params[:id])      
      end

And my show.json.jbuilder file:

json.extract! @appuser, :user_auth_token, :id
end

I've never encountered this before with jbuilder and all of my other jbuilder files work just fine. Any idea what I'm missing?


回答1:


According to documentation, you don't need the end in the jbuilder template, just:

json.extract! @appuser, :user_auth_token, :id

Alternatively, if you are using a Ruby version major than 1.9, you can use this syntax:

json.(@appuser, :user_auth_token, :id)


来源:https://stackoverflow.com/questions/22441569/internal-error-500-jbuilder

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!