using fruit class

master
Matt Huntington 8 years ago
parent 1313ebf969
commit c20ce738af

@ -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

@ -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
Loading…
Cancel
Save