From 90a0059fc961f11c6b23cd35b8bf83eababe87b3 Mon Sep 17 00:00:00 2001 From: Dmitry BRANAVITSKI Date: Sun, 4 Oct 2015 23:55:57 +0300 Subject: [PATCH] fix bag with json.jbuilder --- app/controllers/courses_controller.rb | 1 - app/views/courses/index.json.jbuilder | 3 +++ config/routes.rb | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) create mode 100644 app/views/courses/index.json.jbuilder diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index dd1e377..6beef97 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -3,7 +3,6 @@ class CoursesController < ApplicationController def index @courses=current_user.courses - render json: {}, status: :ok end def create diff --git a/app/views/courses/index.json.jbuilder b/app/views/courses/index.json.jbuilder new file mode 100644 index 0000000..867f43e --- /dev/null +++ b/app/views/courses/index.json.jbuilder @@ -0,0 +1,3 @@ +json.courses do + json.array! @courses, :id, :name +end diff --git a/config/routes.rb b/config/routes.rb index 8b6d5b7..6da0bdc 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -3,5 +3,5 @@ mount_devise_token_auth_for 'User', at: 'auth' - resources :courses + resources :courses, format: 'json' end