문제

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?

도움이 되었습니까?

해결책

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)
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top