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
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
Action Controller
HTTP request
class PeopleController < ApplicationController
# GET /people
def index
@people = Person.all
end
end
Action Controller
HTTP request
class PeopleController < ApplicationController
method
action
# GET /people
def index
@people = Person.all
end
end
Action Controller
HTTP request
class PeopleController < ApplicationController
method
action
# GET /people
def index
@people = Person.all
end
instance variable
end View
Action View
Ruby HTML
<html>
<body>
<h1>Guestbook</h1>
<% @people.each do |person| %>
<p><%= person.name %>: <%= person.bio %></p>
<% end %>
</body>
</html>
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
Ruby on Rails
Part2:
ihower@gmail.com
http://creativecommons.org/licenses/by-nc/2.5/tw/
0 comments
Post a comment