diff --git a/app/controllers/fruits_controller.rb b/app/controllers/fruits_controller.rb index b6f46a0..b538777 100644 --- a/app/controllers/fruits_controller.rb +++ b/app/controllers/fruits_controller.rb @@ -2,10 +2,6 @@ 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: [ - { name: 'apple', color: 'red', readyToEat: true }, - { name: 'banana', color: 'yellow', readyToEat: false }, - { name: 'pineapple', color: 'yelow', readyToEat: true } - ] + render json: Fruit.all end end diff --git a/app/models/fruit.rb b/app/models/fruit.rb new file mode 100644 index 0000000..e56dd51 --- /dev/null +++ b/app/models/fruit.rb @@ -0,0 +1,9 @@ +class Fruit + def self.all + [ + { name: 'apple', color: 'red', readyToEat: true }, + { name: 'banana', color: 'yellow', readyToEat: false }, + { name: 'orange', color: 'orange', readyToEat: false } + ] + end +end