title: Rails Missing JBuilder File Template
body: <p>I've been trying to use Fullcalendar to display events from a JSON feed. The events in the JSON feed are generated by SchoolEventsController. However, the events won't show up on Fullcalendar. Also, viewing the JSON file(school_events/index.json.jbuilder) produces this error:</p>
  
  <p><em>ActionController::UnknownFormat at /calendar.json
  SchoolEventsController#index is missing a template for this request format and variant.
  request.formats: ["application/json"]
  request.variant: []</em></p>
  
  <p>I think I have narrowed my problem down to these two files:</p>
  
  <p>index function in <strong>school_events_controller.rb</strong>:</p>
  
  <pre><code>class SchoolEventsController &lt; ApplicationController
  
      def index
          @events = @calendar.events
          respond_to do |format|
              format.html # index.html.erb
              format.json # index.json.jbuilder?
          end
      end
  
  end
  </code></pre>
  
  <p><strong>school_events/index.json.jbuilder</strong>:</p>
  
  <pre><code>json.array!(@events) do |event|
      date_format = event.all_day? ? '%Y-%m-%d' : '%Y-%m-%dT%H:%M:%S'
      json.id event.id
      json.title event.name
      json.start event.start_time.strftime(date_format)
      json.end event.end_time.strftime(date_format)
      json.url event_url(event, format: :html)
  end
  </code></pre>
  
  <p><strong>Gemfile</strong>:</p>
  
  <pre><code>source 'https://rubygems.org'
  
  git_source(:github) do |repo_name|
    repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?('/')
    "https://github.com/#{repo_name}.git"
  end
  
  ruby '2.3.1'
  gem 'rails', '~&gt; 5.0.2'
  gem 'mime-types', '~&gt; 3.1'
  gem 'paperclip', '~&gt; 5.0'
  gem 'rmagick', '~&gt; 2.15'
  gem 'friendly_id', '~&gt; 5.1'
  gem 'closure_tree', '~&gt; 6.0'
  gem 'ancestry',     '~&gt; 3.0'
  gem 'ranked-model', '~&gt; 0.4.0'
  gem 'mailgun_rails', '0.9.0'
  gem 'nested_form', '0.3.2'
  gem 'event-calendar', github: 'kirandc/event_calendar', require: 'event_calendar'
  gem 'jbuilder', '~&gt; 1.2'
  gem 'ransack', '~&gt; 1.7'
  gem 'sprockets-rails', '~&gt; 3.1'
  gem 'flash_cookie_session', github: 'trevorturk/flash_cookie_session'
  gem 'date_validator', '~&gt; 0.9.0'
  gem 'jquery-rails',        '~&gt; 4.1'
  gem 'jquery-ui-rails',     '~&gt; 6.0'
  gem 'jquery_mobile_rails', '~&gt; 1.3.2'
  gem 'fancybox2-rails', github: 'ChallahuAkbar/fancybox2-rails', tag: 'v0.3.0'
  gem 'kaminari', '~&gt; 1.0'
  gem 'redcarpet', '~&gt; 3.3'
  gem 'pg', '~&gt; 0.21.0'
  gem 'pghero', '~&gt; 1.2'
  gem 'autoprefixer-rails', '~&gt; 7.0'
  gem 'bourbon',            '~&gt; 4.2'
  gem 'normalize-rails',    '~&gt; 4.1'
  gem 'sass-rails',         '~&gt; 5.0'
  gem 'uglifier',           '~&gt; 3.0'
  gem 'bcrypt', '~&gt; 3.1', require: false
  gem 'google-api-client', '~&gt; 0.13.0'
  gem 'recaptcha', '~&gt; 4.1', require: 'recaptcha/rails'
  gem 'yajl-ruby', '~&gt; 1.3', require: false
  gem 'tinymce-rails', '~&gt; 4.3'
  gem 'turbolinks', '~&gt; 5.0'
  gem 'sunspot_rails', '~&gt; 2.2'
  gem 'image_optim',      '~&gt; 0.25.0'
  gem 'image_optim_pack', '~&gt; 0.5.0'
  
  group :production do
    gem 'redis-rails', '~&gt; 5'
    gem 'sitemap_generator', '~&gt; 5.1'
    gem 'newrelic_rpm', '~&gt; 4.0'
    gem 'rollbar', '~&gt; 2.11'
  end
  
  group :development, :production do
    gem 'rack-mini-profiler', '~&gt; 0.10.1'
    gem 'whenever', '~&gt; 0.9.4', require: false
  end
  
  group :development do
    gem 'capistrano',               '~&gt; 3.7',   require: false
    gem 'capistrano-bundler',       '~&gt; 1.1',   require: false
    gem 'capistrano-faster-assets', '~&gt; 1.0',   require: false
    gem 'capistrano-rails',         '~&gt; 1.1',   require: false
    gem 'better_errors',     '~&gt; 2.1'
    gem 'binding_of_caller', '~&gt; 0.7.2'
    gem 'thin', '~&gt; 1.6'
    gem 'guard',            '~&gt; 2.13'
    gem 'guard-livereload', '~&gt; 2.5', require: false
    gem 'brakeman', '~&gt; 3.3', require: false
    gem 'pry', '~&gt; 0.10.3'
    gem 'letter_opener', '~&gt; 1.4'
    gem 'yard', '~&gt; 0.9.5'
    gem 'bullet', '~&gt; 5.0'
    gem 'rubocop',       '~&gt; 0.4',    require: false
    gem 'rubocop-rspec', '~&gt; 1.7',    require: false
    gem 'scss_lint',     '~&gt; 0.54.0', require: false
    gem 'progress_bar', '~&gt; 1.0'
    gem 'sunspot_solr', '~&gt; 2.2'
  end
  
  group :development, :test do
    gem 'spring-commands-rspec',   '~&gt; 1.0'
    gem 'spring-commands-rubocop', '~&gt; 0.2.0'
    gem 'rails-controller-testing', '~&gt; 1.0.1'
    gem 'guard-rspec', '~&gt; 4.6'
    gem 'rspec',       '~&gt; 3.4'
    gem 'rspec-rails', '~&gt; 3.4'
  end
  
  group :test do
    gem 'capybara', '~&gt; 2.7'
    gem 'factory_girl_rails', '~&gt; 4.7'
    gem 'shoulda-matchers', '~&gt; 3.1', require: false
    gem 'launchy', '~&gt; 2.4'
    gem 'simplecov', '~&gt; 0.14.0', require: false
    gem 'database_cleaner', '~&gt; 1.5', require: false
    gem 'webmock', '~&gt; 3.0'
    gem 'accept_values_for', '~&gt; 0.7.2'
  end
  </code></pre>
  
  <p>relevant routes in <strong>routes.rb</strong>:</p>
  
  <pre><code>scope defaults: { calendar_name: 'School Calendar' } do
      get '/calendar/list',             to: 'school_events#list',    as: :school_calendar_list
      get '/calendar/editors',          to: 'school_events#editors', as: :editors_school_calendar
      get '/calendar(/:year(/:month))', to: 'school_events#index',
                                        as: :school_calendar,
                                        constraints: { year: /20(?:1[1-9]|20)/, month: /\d{1,2}/ }
      resources :school_events, path: '/events', except: [:index]
    end
  
    scope '/calendar' do
      get '/edit', to: 'school_events#edit_calendar',
                   defaults: { calendar_name: 'School Calendar' },
                   as: :edit_school_calendar
      put '/',     to: 'school_events#update_calendar',
                   defaults: { calendar_name: 'School Calendar' }
  
      resources :google_syncs, only: %i[new create destroy], as: :school_calendar_google_syncs do
        get :authorize, on: :collection
      end
    end
  </code></pre>
  
  <p>When I replace <code>format.json</code> in SchoolEventsController with <code>format.json { render json: @events }</code>, calendar.json will output(in JSON) all the desired events from my database. I don't want to use those outputs because I would need a messy workaround to rename all the attributes to comply with Fullcalendar's requirements. Does anyone have a way to fix this problem? Thanks in advance!</p>
  
  <p>Note: I'm using Rails 5</p>