Intro to Ruby On Rails

11
Ruby on Rails By Adam Fortuna

Transcript of Intro to Ruby On Rails

Page 1: Intro to Ruby On Rails

Ruby on RailsBy Adam Fortuna

Page 2: Intro to Ruby On Rails

Ruby On Rails

Language

Framework

} }

Page 3: Intro to Ruby On Rails

Ruby Code Sample# Output "Hello World! "say = "Hello World!"puts say

# Output "Hello again!"# five timessay = "Hello again!"5.times { puts say }

# Output "HELLO WORLD!"say['hello'] = "Hello World!"puts say.upcase

Page 4: Intro to Ruby On Rails

hello_world.rb

Page 5: Intro to Ruby On Rails

Ruby on Rails (RoR)

Output HTML, Email, XML and more

Read/write to DB

Unit, Functional and Integration Tests

Accept incoming requests

Process Forms

Validation

Restrict Access

Page 6: Intro to Ruby On Rails

ConventionOver

Configuration

CoC

Page 7: Intro to Ruby On Rails

DRYDon’t Repeat Yourself

Page 8: Intro to Ruby On Rails

Rails PartsController Model ViewStart of all requests

Form input

What view is called

Which layout is used

Access DB through Model

Restrict Access(administrator only action?)

Access to database

Real world Objects(Hotel, Resort, etc)

Validation(Hotel.valid?)

Additional methods(User.full_name)

Before hotel save?After hotel Create?

Web pages

Emails

Stylesheets

Javascript

Page 9: Intro to Ruby On Rails

rails hotelmanager

Page 10: Intro to Ruby On Rails

RakeCreate or destroy database

Migrate database forward or back

Generate documentation

Run tests

Deploy

See stats

rake --tasks

Page 11: Intro to Ruby On Rails

ActiveRecord

An object that wraps a row in a database table or view, encapsulates

the database access, and adds domain logic on that data.

- Wikipedia