parent
4fa8b1df60
commit
de856cbe55
@ -1,9 +1,5 @@
|
|||||||
class PeopleController < ApplicationController
|
class PeopleController < ApplicationController
|
||||||
def index
|
def index
|
||||||
render json: [
|
render json: Person.all
|
||||||
{ name: 'Joey', age:12 },
|
|
||||||
{ name: 'Sarah', age:52 },
|
|
||||||
{ name: 'Cthulhu', age: 8000 }
|
|
||||||
]
|
|
||||||
end
|
end
|
||||||
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