Creating a Jbuilder in the Rails 5 API Mode

I want to use Jbuilder with Rails 5.0.0.beta1.1 in API mode. Out of the box, this does not work even when creating an application / presentation directory.

For example, I have:

# app/controllers/tests_controller.rb class TestsController < ApplicationController # The requests gets inside the action def test end end # app/views/tests/test.json.jbuilder json.test "It works!" 

The error I get is

No template found for TestsController#test, rendering head :no_content

I think I need to change some things in the configuration files. What should I do?

+8
ruby-on-rails
source share
1 answer

Performing explicit visualization from such a controller works:

 render 'controller_name/action.json.jbuilder' 
+3
source share

All Articles