title: Basic usage of Jbuilder in a controller
body: <p>In a Rails (5.2) app, I'm trying to use JBuilder to return some JSON as response.</p>
  
  <p>I have added JBuilder in my <code>Gemfile</code>.</p>
  
  <pre><code># Gemfile
  ...
  gem 'jbuilder', '~&gt; 2.5'
  ...
  
  # Gemfile.lock
  ...
  jbuilder (2.8.0)
  ...
  </code></pre>
  
  <p>According to JBuilder documentation:</p>
  
  <blockquote>
    <p>You can also extract attributes from array directly.</p>
    
    <p>@people = People.all</p>
    
    <p>json.array! @people, :id, :name</p>
    
    <p>=> [ { "id": 1, "name": "David" }, { "id": 2, "name": "Jamie" } ]</p>
  </blockquote>
  
  <p>Now, in my controller, I have added the following:</p>
  
  <pre><code>def index
    respond_to do |format|
      format.json { render json.array! User.all, :email, :full_name }
    end
  end
  </code></pre>
  
  <p>But I get</p>
  
  <blockquote>
    <p>NameError - undefined local variable or method `json' for
    UsersController:0x00007fe2f966f150 16:55:40 rails.1<br>
    | => Did you mean?  JSON:</p>
  </blockquote>
  
  <p>Am I missing anything here?</p>