parent
4fa8b1df60
commit
de856cbe55
@ -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
|
||||
|
||||
@ -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
|
||||
Loading…
Reference in new issue