Tom Hammond
Tom Hammond

Reputation: 6080

Internal Error 500 jbuilder

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?

Upvotes: 1

Views: 888

Answers (1)

markets
markets

Reputation: 7033

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)

Upvotes: 2

Related Questions