0% found this document useful (0 votes)
46 views

Lecture5

Ruby on Rails is an open source web application framework that aims to increase the speed and ease of developing database-driven websites. It uses the Model-View-Controller design paradigm and includes all the components needed to build a full-stack web application, including models, views, controllers, and more. Ruby on Rails takes advantage of Ruby's simplicity and flexibility to minimize the amount of code needed to build robust applications.

Uploaded by

gippi89
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
46 views

Lecture5

Ruby on Rails is an open source web application framework that aims to increase the speed and ease of developing database-driven websites. It uses the Model-View-Controller design paradigm and includes all the components needed to build a full-stack web application, including models, views, controllers, and more. Ruby on Rails takes advantage of Ruby's simplicity and flexibility to minimize the amount of code needed to build robust applications.

Uploaded by

gippi89
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 17

Ruby on Rails

Introduction

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

Offers skeleton code frameworks (scaffolding) from the outset.

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 the successful combination of:


Smalltalk's conceptual elegance, Python's ease of use and learning, and Perl's pragmatism

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

Sample Ruby Code:


Here is a sample Ruby code to print "Hello Ruby # The Hello Class class Hello def initialize( name ) @name = name.capitalize end def salute puts "Hello #{@name}!" end end # Create a new object h = Hello.new("Ruby") # Output "Hello Ruby!" h.salute

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 %>.

Save the code in erbdemo.rb file


<% page_title = "Demonstration of ERb" %> <% salutation = "Dear programmer,"%> <html> <head> <title><%= page_title%></title> </head> <body> <p><%= salutation %></p> <p>This is an example of how ERb fills out a template.</p> </body> </html> c:\ruby\>erb erbdemo.rb

Example

This will produce following result:


<html> <head> <title>Demonstration of ERb</title> </head> <body> <p>Dear programmer,</p> <p>This is an example of how ERb fills out a template.</p> </body> </html>

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

Full Stack Framework


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

Ruby on Rails Installation


To develop a web application using Ruby on Rails Framework, install the following software: Ruby The Rails framework A Web Server
WEBrick Web Server, which comes with Ruby Apache or lightTPD

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

Ruby on Rails is a Server Side scripting language / framework.

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.

You might also like