Lecture5
Lecture5
Introduction
Aims to increase the speed and ease with which database-driven web sites can be created
Applications using the Rails framework are developed using the Model-View-Controller design paradigm
History
Ruby on Rails was developed and released in 2004 by David Heinemeier Hansson, a developer at 37Signals. Various major releases, starting with the stable 1.0 release in December of 2005 and a major update in version 1.1 released in March of 2006. Stable Release : 2.3.5 / November 27, 2009 Preview Release: 3.0.0 / February 4, 2010 Enables the developer to build robust web applications faster, using less code than other platforms.
What is Ruby ?
Ruby is
A High Level Programming Language Interpreted like Perl, Python. Object-Oriented Like Smalltalk, Ada, Java. Originated in Japan and Rapidly Gaining Mindshare in US and Europe.
Ruby on Rails is an open source free web application framework Aims to increase the speed and ease with which database-driven web sites can be created
Why Ruby ?
Following are greatest factors: Easy to learn Open source (very liberal license) Rich libraries Very easy to extend Object-Oriented Less Coding with fewer bugs Helpful community
Embedded Ruby:
Ruby provides you with a program called ERb (Embedded Ruby), written by Seki Masatoshi ERb allows you to put Ruby code inside an HTML file. You need to know only two things to prepare an ERb document:
If you want some Ruby code executed, enclose it between <% and %> If you want the result of the code execution to be printed out, as part of the output, enclose the code between <%= and %>.
Example
What is Rails
An extremely productive web-application framework. Written in Ruby by David Heinemeier Hansson. You could develop a web application at least ten times faster with Rails than you could with a typical Java framework. An open source Ruby framework for developing database-backed web applications. Your code and database schema are the configuration! No compilation phase required
Includes everything needed to create a database-driven web application using the Model-View-Controller pattern. Being a full-stack framework means component for creating web applications:
Action Controller [Syntax(ActiveController::Base class)] Action View Active Record Action Mailer Active Resource Active Support
Model-View-Controller
Model
A model represents the information (data) of the application and the rules to manipulate that data. Primarily used for managing the rules of interaction with a corresponding database table. One table in your database will correspond to one model in your application. The bulk of your applications business logic will be concentrated in the models.
View
Views represent the user interface of your application. Views are often HTML files with embedded Ruby code that performs the presentation of the data. Views handle the job of providing data to the web browser or other tool that is used to make requests from your application
Controller
Controllers provide the glue between models and views. Responsible for processing the incoming requests from the web browser, interrogating the models for data, and passing that data on to the views for presentation.
MVC
A Database System
including MySQL,PostgreSQL, SQLite, Oracle, DB2 and SQL Server
Applications
Ideal solution for Web-based applications that require database connections. Doesnt require any configuration files, except for a database configuration file. Basecamp is the original Ruby on Rails application from which the framework was extracted. Another example of a very popular web application built using Ruby on Rails is Backpack.
Development Environments
RadRails: A Rapid Application Development IDE for the Ruby on Rails framework. Built on the Eclipse IDE. Free and open source; cross-platform, stand-alone IDE or Eclipse plug-in Embedded database navigator and query console Fast, integrated debugger Syntax highlighting, code assist, error reporting, outlining, etc. Unied, deep support for Ruby, Rails, RHTML, JS, HTML and CSS. TextMate: TextMate is a general-purpose GUI text editor for Mac OS X. Features: Tabs Recordable macros Folding sections and snippets Shell integration Extensible bundle system, all built around its novel scope system.
Client-side or Server-side
Such languages don't have a compiler or a compilation phase per se, instead, they use an interpreter -- a program that runs on the web server -- to translate handwritten code into machine-executable code on the fly.