development with ruby on railskremer.cpsc.ucalgary.ca › courses › seng403 › w2012... ·...
TRANSCRIPT
DEVELOPMENT WITH RUBY ON RAILS
Colin Williams
Eliezer Mar Manarang
Mitchell Craig
Tam Nguyen
Becker Luu
PRESENTATION OVERVIEW• What is Ruby on Rails?
• History
• Philosophy
• Technical Information
• Competition• Tutorial
RUBY ON RAILS - WHAT IS IT?
• Ruby on Rails (or just Rails) is an open source web application framework.
• Written in the Ruby programming language.
• Designed to make programming web applications easier.
• Abstracts the commonly used and repetitive tasks.
HISTORY• Created in 2003 by David Heinemeier Hansson.
• Developed while he was working on a Ruby-based project for 37signals.
• Extracted from some his work on Basecamp, a project management tool.
MORE HISTORY...• First publicly released in July 2004 as an open source project.
• Reached a milestone in 2006:
Apple announced that Rails would be bundled with Mac OS X v10.5 Leopard.
FOUNDING BELIEFS AND
PHILOSOPHIESCOC
DRY
REST
CONVENTION OVER CONFIGURATION
• Developer only needs to specify unconventional aspects of the application.
• Makes assumptions about what you want to, and how to do it; so you don't have to!
• Makes for an "opinionated" framework.
• Just a convention!
DON'T REPEAT YOURSELF• Is the code DRY enough?
• No? Less clarity, more inconsistencies.
• Reuse code as much as possible.
• Easier to make changes later on in development.
REPRESENTATIONAL STATE TRANSFER
• Specifies a pattern that web applications should follow in development.
• Organizing your application around resources and standard HTTP verbs.
• Identify resources, manipulation of resources, self-descriptive messages.
• Follow the basic CRUD operations (create, read, update, delete)
• Example:
resources :photos
DELETE /photos/17
TECHNICAL INFORMATION:
Rails - a full-stack web application development
framework
TECHNICAL INFORMATION:INTRODUCTION
Philosophies
Default configuration
Ease of use
TECHNICAL INFORMATION:INTRODUCTION - DIRECTORY STRUCTURE
Some of the directories are:• app
• config
• db
• lib
• log
• test
TECHNICAL INFORMATION:ARCHITECTURE
MVCModel-View-Controller
encapsulate show coordinate/transmit
TECHNICAL INFORMATION:ARCHITECTURE - MVC
• Model - encapsulates the data, data access methods, business logic methods
• View - view templates rendered to be show.
• Controller - requests/responds with the user browser, communications with Model and View layer.
TECHNICAL INFORMATION: ARCHITECTURE - MVC TECHNICAL INFORMATION: RAILS COMPONENT - MVC
! ! ! ActionController
ActionView ActiveRecord
TECHNICAL INFORMATION:MODEL - ACTIVERECORD
RelationalDatabase Application
?
TECHNICAL INFORMATION:MODEL - ACTIVERECORD
RelationalDatabase
Application
ORM Models• Data• Data Accessor• Business Logic
Methods
TECHNICAL INFORMATION:MODEL - ACTIVERECORD
• Encapsulates data via objects of classes.
• Does Object-Relational Mapping to convert relational database to object-oriented classes.
• Has Data-access methods
• Has Business logic methods for processing
• All of these are called Models.
• Changes in data results in changes in both database and Model.
• ActiveRecord::BaseActionController
TECHNICAL INFORMATION:CONTROLLER - ACTIONCONTROLLER
TECHNICAL INFORMATION:CONTROLLER - ACTIONCONTROLLER
• Under ActionPack library
• 1 Model/1 View = 1 Controller
1 active entity that user interacts that changes view = 1 method inside the controller (action method)
• Action method handles routing.
• ActionController::Base
TECHNICAL INFORMATION:CONTROLLER - ACTIONCONTROLLER
Routing
TECHNICAL INFORMATION:VIEW - ACTIONVIEW
• Under ActionPack library
• Templates for different user views
• Mostly made of HTML and .erb (embedded ruby) files
• Doesn't contain business logic methods
TECHNICAL INFORMATION:OTHER LIBRARIES/COMPONENTS
• ActionDispatch
• ActionMailer
• ActiveModel
• ActiveResource
• ActiveSupport
• Railities
• more classes could be seen at Rails' API webpage:http://api.rubyonrails.org
COMPETITORS
COMPETITORS: PHP AND JAVA
• More flexibility
• More manual setup
• Claimed to be more scalable
COMPETITORS: DJANGO AND ZEND
• Very similar as they are full-stack frameworks
• Zend based off of PHP
o It inherits the flexibility
• Django based off of Python
.NET MVC• Released in 2009
• Based on C#
• Follows MVC design pattern
• Found to lack community support
o Likely due to its relatively young age
TUTORIAL TIME :)
REFERENCES:- Ruby on Rails team. “Ruby on Rails Documentation.” Internet: http://api.rubyonrails.org/ [Apr. 9, 2012]
- Ruby on Rails team. “Ruby on Rails Guides: Getting Started with Rails.” Internet: http://guides.rubyonrails.org/getting_started.html [Apr. 9, 2012]
- T. Fisher. Ruby on Rails(r) Bible. Indianapolis, IN: Wiley Publishing Inc., 2008, pp.67 - 74, 107-109, 147-149, 173-179
- T. Reenskaug. “Trygve/MVC.” Internet: http://heim.ifi.uio.no/~trygver/themes/mvc/mvc-index.html, [Feb. 26, 2012]
- M. Fowler. “P of EAA: Active Record.” Internet: http://www.martinfowler.com/eaaCatalog/activeRecord.html [Apr. 9, 2012]
- Ruby Programming Language team. “Ruby Programming Language.” Internet: http://www.ruby-lang.org/en/, [Feb. 26, 2012]
- Ruby on Rails team. “Ruby on Rails.” Internet: http://rubyonrails.org/, [Feb 26, 2012]
- R.T. Fielding. “Architectural Styles and the Design of Network-based Software Architectures.” Internet: http://www.ics.uci.edu/~fielding/pubs/dissertation/top.htm, [Feb. 26, 2012]