13. DB schema
Ruby
class CreatePeople < ActiveRecord::Migration
def self.up
create_table :people do |t|
t.string :name
t.integer :age
t.date :birthday
t.text :bio
t.timestamps
end
end
def self.down
drop_table :people
end
end
14. Active Record
ORM
class Person < ActiveRecord::Base
#
end
person = Person.new
person.name "ihower"
person.age = 18
person.save
person = Person.find(1)
puts person.name # ihower
15. Action Controller
HTTP request
class PeopleController < ApplicationController
# GET /people
def index
@people = Person.all
end
end
16. Action Controller
HTTP request
class PeopleController < ApplicationController
method
action
# GET /people
def index
@people = Person.all
end
end
17. Action Controller
HTTP request
class PeopleController < ApplicationController
method
action
# GET /people
def index
@people = Person.all
end
instance variable
end View
18. Action View
Ruby HTML
<html>
<body>
<h1>Guestbook</h1>
<% @people.each do |person| %>
<p><%= person.name %>: <%= person.bio %></p>
<% end %>
</body>
</html>
21. Thank you.
Get to the Point! (http://johnwlong.com/slides/gettothepoint/)
Ruby on Rails slide by thegiive in COSCUP
Delivery of the key adoption Factors and key characteristics of
companies using ruby on rails by Michel Barbosa
22. Ruby on Rails
Part2:
ihower@gmail.com
http://creativecommons.org/licenses/by-nc/2.5/tw/