From c67b74bc23b212ee3fbf994eb5644a310ecfbf3f Mon Sep 17 00:00:00 2001 From: Matt Huntington Date: Thu, 15 Mar 2018 10:24:47 -0400 Subject: [PATCH] basic route to controller --- app/controllers/fruits_controller.rb | 7 +++++++ config/routes.rb | 2 ++ 2 files changed, 9 insertions(+) create mode 100644 app/controllers/fruits_controller.rb diff --git a/app/controllers/fruits_controller.rb b/app/controllers/fruits_controller.rb new file mode 100644 index 0000000..0305a7d --- /dev/null +++ b/app/controllers/fruits_controller.rb @@ -0,0 +1,7 @@ +class FruitsController < ApplicationController + def index + # render({ :json => { :message => 'hi', :status => 200 } }) + # render json: message: 'hi', status: 200 # doesn't work because nested objects are unguessable + render json: { message: 'hi', status: 200 } + end +end diff --git a/config/routes.rb b/config/routes.rb index 787824f..144c764 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,3 +1,5 @@ Rails.application.routes.draw do # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html + get '/fruits', to: 'fruits#index' + # get('/fruits', { :to => 'fruits#index' }) end