diff --git a/app/controllers/people_controller.rb b/app/controllers/people_controller.rb index 7bad454..3585a4c 100644 --- a/app/controllers/people_controller.rb +++ b/app/controllers/people_controller.rb @@ -1,9 +1,5 @@ class PeopleController < ApplicationController def index - render json: [ - { name: 'Joey', age:12 }, - { name: 'Sarah', age:52 }, - { name: 'Cthulhu', age: 8000 } - ] + render json: Person.all end end diff --git a/app/models/person.rb b/app/models/person.rb new file mode 100644 index 0000000..38bc5e2 --- /dev/null +++ b/app/models/person.rb @@ -0,0 +1,9 @@ +class Person + def self.all # a static function that's called on the class itself, not an instance + [ ## ruby functions return the last line of code, so no need for an explicit 'return' statement + { name: 'Joey', age:12 }, + { name: 'Sarah', age:52 }, + { name: 'Cthulhu', age: 8000 } + ] + end +end