Rubyonrails 090715105949-phpapp01

26
Ruby On Rails Building Web Applications Is Fun!

Transcript of Rubyonrails 090715105949-phpapp01

Page 1: Rubyonrails 090715105949-phpapp01

Ruby On RailsBuilding Web Applications Is Fun!

Page 2: Rubyonrails 090715105949-phpapp01

Rails is a full-stack framework for developing database-backed web applications according

to the Model-View-Control pattern.

– www.rubyonrails.org - Ruby on Rails official site

What is Ruby on Rails?

Page 3: Rubyonrails 090715105949-phpapp01

• Written in Ruby• Creator of Ruby on Rails

– David Heinemeier Hansson

• Birth: July 2004• Latest: 2.1.1: 4 September 2008• Based on SmallTalk, Perl, Lisp• Not strongly typed

RoR Trivia

Page 4: Rubyonrails 090715105949-phpapp01

Dynamic, high level, interpreted, pure object-orientated language.

“Ruby is designed to make programmers happy”Yukihiro Matsumoto aka Matz

What is Ruby?

Page 5: Rubyonrails 090715105949-phpapp01

• Creator of Ruby– Yukihiro Matsumoto aka Matz

• Birthday: 24 February 1993• Originated in Japan and Rapidly Gaining Mindshare in US and Europe.

Ruby Trivia

Page 6: Rubyonrails 090715105949-phpapp01
Page 7: Rubyonrails 090715105949-phpapp01

Design Principles

Page 8: Rubyonrails 090715105949-phpapp01

• Separate data (model) from user interface (view)

• Model– data access and business logic– independent of the view and controller

• View– data presentation and user interaction– read-only access to the model

• Controller– handling events– operating on model and view

Design Principles

Model - View - Controller

Page 9: Rubyonrails 090715105949-phpapp01

Design Principles

Database Persistence

• OR mapping– Active Record design pattern

• migrations– incremental schema management

• multiple db adapters– MySQL, PostgreSQL, SQLite, SQL Server, IBM DB2,

Informix, Oracle

Page 10: Rubyonrails 090715105949-phpapp01

Design Principles

Full Stack Framework

• MVC suite• built-in webserver• default db adapter• AJAX, web services, email• test framework• plugins

Page 11: Rubyonrails 090715105949-phpapp01

• fixed directory structure– everything has its place – source files, libs, plugins,

database files, documentation etc

• file naming conventions– e.g. camel case class name, underscore file name

• database naming conventions– table names, primary and foreign keys

• standard configuration files– e.g. database connections, environment setting definitions

(development, production, test)

Design Principles

Convention over Configuration

Page 12: Rubyonrails 090715105949-phpapp01

• reusing code– e.g. view elements

• reusing data– e.g. no need to declare table field names – can be read from

the database

• making each line of code work harder– e.g. mini languages for specific domains

• object-relational mapping• metaprogramming

– dynamically created methods

Design Principles

DRY - Don’t Repeat Yourself

Page 13: Rubyonrails 090715105949-phpapp01

MVC Architecture

Page 14: Rubyonrails 090715105949-phpapp01

MVC Architecture

MVC Architecture

Page 15: Rubyonrails 090715105949-phpapp01

• Object Relational Mapping– “ActiveRecord”

• Less Database “glue” Code• Logging for Performance Checking

MVC Architecture

Model - ActiveRecord

Page 16: Rubyonrails 090715105949-phpapp01

MVC Architecture

Model : Rules

• Table Names– Plurals

• Attribute Names– id for primary key in table– table_id for foreign key in other table

Page 17: Rubyonrails 090715105949-phpapp01

MVC Architecture

View - ActionView

• multiple template types– oldest and basic: erb (embedded ruby), similar to e.g. jsp– remote javascript templates– xml templates

• easy reuse of view elements– file inclusion – layouts, templates, partials– multiple standard "helpers" – common html element

generators (e.g. form elements, paginators)

• easy AJAX integration

Page 18: Rubyonrails 090715105949-phpapp01

MVC Architecture

Controller : ActionController

• Method name matches view folder– users_controller.rb works for

/views/users/***.rhtml– called “actions”– all view’s methods will sit there

• Ability to– CRUD– Flash– Redirect

Page 19: Rubyonrails 090715105949-phpapp01

Some Comparisons

Page 20: Rubyonrails 090715105949-phpapp01

RoR vs. Java

 Comparison of Rails and J2EE stacks

Page 21: Rubyonrails 090715105949-phpapp01

Usage & Support

Page 22: Rubyonrails 090715105949-phpapp01

Usage & Support

Web Servers

• Lighttpd• Mongrel• WEBrick• Apache

Page 23: Rubyonrails 090715105949-phpapp01

Usage & Support

RoR Databases

• Mysql• Oracle• Postgre Sql• SqlLite

Page 24: Rubyonrails 090715105949-phpapp01

Usage & Support

Websites on Rails

Page 25: Rubyonrails 090715105949-phpapp01

Usage & Support

Companies Using Rails

Page 26: Rubyonrails 090715105949-phpapp01

Thank You.!!