SlideShare uma empresa Scribd logo
1 de 16
.
09
The Ruby on Rails Web
Framework
Technical Report
Anthony N. Ilukwe
3
Executive Summary
Over the past three years, Ruby on Rails has become one of the most popular web application
frameworks for developers. Ruby on Rails, shortly known as RoR, has redefined the way web
applications can be created and deployed.
One of its underlying principles, “Convention over configuration,” defines the development
approach that emphasizes clean, concise code; making RoR applications easy to understand,
code, test, and debug.
RoR has a series of features such as code generation, security, validation, transaction, and
testing; making it highly compact, portable, and tidy. It is also bundled with a web server,
WEBRick; JavaScript library, Prototype; and AJAX library, script.aculo.us. These in-built libraries
eliminate the need to import external tools, and make it easier for developers to integrate a
wide variety of dynamic effects into their applications.
RoR is developed with the Ruby programming language.
A RoR application can be created in minutes. After installing the 3 main components: Ruby,
Rails (framework), and MySQL on a machine; a series of simple commands can get a basic Ruby
on Rails environment up and running.
4
Table of Contents
Executive Summary............................................................................................................... 3
1. Introduction ...................................................................................................................... 5
2. Ruby on Rails..................................................................................................................... 5
2.1 Structure................................................................................................................................ 6
2.1.1 Environment .................................................................................................................... 6
2.1.2 MVC Pattern .................................................................................................................... 6
2.1.3 Libraries ........................................................................................................................... 7
2.1.4 Emphasis on convention.................................................................................................. 8
2.2 Features................................................................................................................................. 8
2.2.1 Built-in JavaScript libraries .............................................................................................. 8
2.2.2 Web Services ................................................................................................................... 8
2.2.3 Scaffolding ....................................................................................................................... 9
2.2.4 Built-in web server........................................................................................................... 9
2.2.5 Rake ................................................................................................................................. 9
3. Ruby: The Language........................................................................................................... 9
3.1 History & Description ............................................................................................................ 9
3.2 Advantages of Ruby............................................................................................................. 10
3.3 Syntax .................................................................................................................................. 10
3.4 Examples of Ruby Code....................................................................................................... 10
3.4.1 Simple Hello Word......................................................................................................... 10
3.4.2 Simple Loop ................................................................................................................... 10
3.4.3 Arrays............................................................................................................................. 11
3.4.4 String Methods .............................................................................................................. 12
4. Inside RoR Development.................................................................................................. 12
4.1 The development environment .......................................................................................... 12
4.1.1 Creating a simple application ........................................................................................ 12
4.1.1.1 Model...................................................................................................................... 14
4.1.1.2 View......................................................................................................................... 15
4.1.1.3 Controller................................................................................................................ 15
5. Conclusion....................................................................................................................... 16
6. References....................................................................................................................... 17
5
1. Introduction
Since the early 90’s, several software frameworks have been created for the purpose of
developing database and interactive, or action-driven websites, or web applications.
There are a number of different web application frameworks, from which developers
have a wide variety to choose. These web application frameworks vary according to
their scripting languages, back-end server compatibility, configuration, structure, built-in
functionality, and supported frameworks.
However, most web application frameworks have similar features such as:
• Authentication
• Databases
• HTML or Layout directory
• Libraries
• Computer-to-computer interaction
Popular web application frameworks include: ASP.NET, Echo, JQuery, Scheme,
ColdFusion, Python, Perl, PHP, and Ruby.
This report will discuss Ruby On Rails as a Ruby web application framework. It will detail
the main components, features, and structure of this framework, as well as highlighting
why it is being embraced by a growing number of Web 2.0 developers.
2. Ruby On Rails
Ruby On Rails (RoR) is one of a growing number of free “Open Source” web application
frameworks available. The source code for these “Open Source” frameworks is available
for developers to tweak, and as a result the collaborative effort is beneficial to the
entire community of developers and users.
RoR was first released by a team led by Danish programmer David Heinemeier-Hansson
in 2004, and several versions have been released ever since.
6
In addition to its relatively compact structure and built-in features, one of the main
distinctions of RoR is the “Convention over Configuration” philosophy that defines the
underlying development techniques. This will be discussed in the next section.
2.1. Structure
2.1.1. Environment
The RoR environment runs on web servers such as WEBrick, Mongrel, and Apache.
Apache is the most widely used of the aforementioned, although WEBRick and Mongrel
were initially used to run RoR.
Popular open-source relational database management system MySQL is most commonly
used to provide database services for RoR applications, as it is also built for smooth
functionality with Apache web servers. Other database systems such as Oracle and
SQLite can also be used.
2.1.2. MVC Pattern
RoR applications are structured according to the MVC (Model View Controller) software
engineering pattern. This structural pattern ensures that the interface, application, and
database files are separated in a manner that especially suites agile application
development.
When a RoR application development project is initiated, the application folder is
created with a subfolder for each of these components (model, view, and controller).
2.1.3. Libraries
There are several libraries that merge to form the RoR framework. These libraries
provide different functions in the general framework structure, such as web services,
database-mapping and mail services.
Some of these libraries include:
• ActivePack
• ActiveResource
7
• ActiveRecord
• ActiveMailer
• ActiveSupport
Figure 1: Ruby On Rails Architecture
2.1.4. Emphasis on Convention
RoR follows a strict naming convention, which when correctly used, easily identifies
various components in an application, from fields to objects and variables.
Database tables have to be given names in plural, as they represent objects. And certain
table attributes have to follow a strict pattern. For example, a database table would be
called “animals,” representing an Animal object in the system, while the foreign key
column would be named “animal_id.”
8
The creators of RoR wanted a web framework that reduced a lot of the code
redundancy often associated with other frameworks like PHP and ASP. This convention
leads to concise, clever, and arguably clean lines of code that can be easily debugged
and modified.
In a subsequent section, this will be discussed in more detail.
2.2. Features
2.2.1. Built-in JavaScript Libraries
RoR is shipped with JavaScript library or framework Prototype, which offers a variety of
client-side dynamic effects for web applications. This bundling makes it easy for
developers to use Javascript commands and scripting within Rails applications, without
having to import – the likely case when developing with most other web frameworks.
Another Javascript/AJAX library, script.aculo.us, is also bundled with RoR. Like
Prototype, Script.aculo.us is useful for visual effects, and it additionally provides a range
of user interface elements as well as more dynamic effects.
2.2.2. Web Services
RoR uses the web services SOAP and RESTful to support its computer-to-computer
network interaction.
2.2.3. Scaffolding
One of the handiest features that RoR has to offer is scaffolding. This is a technique
through which code is generated for an application by simply entering the
corresponding commands.
For example, the command line entry scaffold :model_name will generate a
series of Ruby files that server as a bridge between the controller and the model
(database).
9
2.2.4. Built-in Web Server
Ruby On Rails contains a built-in web server called WEBrick. This built-in web server
does not necessarily have to be run with a local Rails application, but it serves the
purpose of creating a complete development environment within the package.
2.2.5. Rake
Rake is a feature than enables developers to use simple pre-built commands to perform
tasks like database migrations, backups, and cache generation. This is one of the
handiest features of Ruby On Rails, as it enables developers to use pre-made rake
commands, and also to create their own; hence using less code and saving time.
For example, if an update is made to a database schema, typing rake db:migrate will
instantly synchronize all the model files related to the updated schema. More examples
of rake will be shown later.
3. Ruby: The Language
As stated earlier, the Ruby On Rails framework is based on the Ruby programming
language. The next subsections give a detailed overview of Ruby.
3.1. History & Description
Ruby was created by Japanese programmer Yukihiro Matsumoto with the goal of a cross-
platform, object-oriented programming language that also incorporates procedural
programming techniques in addition to practices such as automatic garbage collection,
memory management and code generation.
Ruby was initially developed with C, and has syntax that is similar to that of Perl, Python,
and SmallTalk. In another section, I will substantiate more on Ruby grammar.
Unlike Java and C++, Ruby instance variables are always private and cannot be accessed
without accessor methods. These Ruby accessor methods are a lot simpler than in Java, and
some examples are included in Section 3.4.
10
3.2. Advantages of Ruby Over Other Languages
• Portability
• Ability to overload operators
• Auto garbage-collection
• Flexibility
• Exception handling
• Large standard library
• Iterators and closures
3.3. Syntax
One of Ruby’s distinctive features is the somewhat intrinsic detail involved with the
grammar and syntax.
Some of the major syntax rules are listed below:
• Line breaks are used to signify the end of a statement
• Instead of brackets, keywords are used to signify class and method definitions
• Local variables must always begin with lower case characters
• Constants must always begin with upper case characters
• Instance variables start with @
• Global variables start with $
• Comment blocks start with #
3.4. Examples of Ruby Code: Methods and Classes
3.4.1. Simple Hello Word
print "Hello world!"
This simply prints out the text “Hello world!”
3.4.2. Simple Loop
#!/usr/bin/Ruby
for ss in 1...5
print ss, " Hellon";
end
11
Prints:
Hello
Hello
Hello
Hello
Hello
3.1.1. A More Advanced Loop
puts "@@@@@"
ss = 5
while ss > 0
puts ss
ss -= 2
if ss == 1
ss += 5
end
Prints out:
@@@@@
5
3
6
4
2
3.4.3. Arrays
Here, I created an array and used the .each methods to loop through:
cars = ["Honda", "Nissan", "Toyota", "GMC", "Ford", "Chrysler"]
cars.each { |i| print i, "n"}
Prints:
Honda
Nissan
Toyota
GMC
12
Ford
Chrysler
3.4.4. String Methods
Below are examples of simple String operations, for a String defined as “Yes we can”
newstring = "Yes we can" #declare variable
newstring.capitalize # prints "Yes We Can"
newstring.downcase # prints "yes we can"
newstring.reverse # prints "nac ew sey"
As I’ve shown in this section, Ruby is a very easy language to learn, and the similarity to
common English makes the syntax less of a burden for beginners.
4. Inside Ruby On Rails Development
This section will examine the creation of a basic Ruby On Rails application, as well as an
inside look at the Ruby On Rails application environment.
4.1. The development environment
4.1.1. Creating a simple application
After installing Ruby, Rails, and MySQL database, running the following terminal
command inside the development directory will create an empty Ruby On Rails
application called “Apollo.”
rails apollo
As seen in the next graphic, this command creates the entire application directory
structure and a series of Ruby, HTML, and database files.
13
Figure 2: Application directories and files being created with the “rails” command
14
Figure 3: Directory structure of the empty Apollo application.
4.1.1.1. Model
The model folder consists of Ruby class files that define every domain (entity) in the
application model. That is, for each table on the database, there is a corresponding
class in this folder. The class defines the attributes (columns) of each domain.
15
4.1.1.2. View
The view folder contains the interface files through which the application is viewed
by users. These files are mostly HTML files that contain slices of RHTML (embedded
Ruby code) to drive the web page’s dynamics.
4.1.1.3. Controller
This folder consists of Ruby classes that communicate with the application data,
based on user interaction with the view layer. These Ruby files perform a variety of
functions in order to ensure that data is being fetched from the database tables and
displayed on the interface, when necessary.
Figure 4: Model View Controller Architecture
16
5. Conclusion
The ease and simplicity of Ruby On Rails makes it possible for an individual to handle a web
development project that would have conventionally been done by a team.
As web development reaches newer and greater heights; with unending potential for
speed, efficiency, and dynamism, Ruby On Rails will become a staple for some of the great
web applications yet to come.
17
References
Corbridge, R., Introducing Ruby On Rails, Software Developer.
http://www.softwaredeveloper.com/features/intro-to-Ruby-on-rails-part-two-
043007. 2007.
Introducing Ruby On Rails. The Workshop.
http://www.eclips3media.com/workshop/2007/06/28/introducing-Ruby-on-rails.
2007.
Ruby On Rails. (2009, January 12). In Wikipedia, the free encyclopedia. Retrieved
January 17, 2009, from http://en.wikipedia.org/wiki/Ruby_on_Rails
Ruby (Programming Language). (2009, January 3). In Wikipedia, the free
encyclopedia. Retrieved January 8, 2009, from
http://en.wikipedia.org/wiki/Ruby_(programming_language)

Mais conteúdo relacionado

Semelhante a RubyOnRails

Ruby On Rails
Ruby On RailsRuby On Rails
Ruby On Railsiradarji
 
Ror Seminar With agilebd.org on 23 Jan09
Ror Seminar With agilebd.org on 23 Jan09Ror Seminar With agilebd.org on 23 Jan09
Ror Seminar With agilebd.org on 23 Jan09Shaer Hassan
 
Ruby on rails backend development preferred choice for product owners
Ruby on rails backend development preferred choice for product ownersRuby on rails backend development preferred choice for product owners
Ruby on rails backend development preferred choice for product ownersKaty Slemon
 
Ruby Rails Web Development.pdf
Ruby Rails Web Development.pdfRuby Rails Web Development.pdf
Ruby Rails Web Development.pdfAyesha Siddika
 
The Birth and Evolution of Ruby on Rails
The Birth and Evolution of Ruby on RailsThe Birth and Evolution of Ruby on Rails
The Birth and Evolution of Ruby on Railscompany
 
8 Common Ruby on Rails Development Mistakes to Avoid
8 Common Ruby on Rails Development Mistakes to Avoid8 Common Ruby on Rails Development Mistakes to Avoid
8 Common Ruby on Rails Development Mistakes to Avoidrorbitssoftware
 
Ruby on Rails : First Mile
Ruby on Rails : First MileRuby on Rails : First Mile
Ruby on Rails : First MileGourab Mitra
 
Top 20+ React Libraries Every JavaScript Professional Should Know in 2023
Top 20+ React Libraries Every JavaScript Professional Should Know in 2023Top 20+ React Libraries Every JavaScript Professional Should Know in 2023
Top 20+ React Libraries Every JavaScript Professional Should Know in 2023Inexture Solutions
 
Ruby On Rails
Ruby On RailsRuby On Rails
Ruby On Railsanides
 
8 awesome benefits of ruby on rails application development
8 awesome benefits of ruby on rails application development 8 awesome benefits of ruby on rails application development
8 awesome benefits of ruby on rails application development rorbitssoftware
 
Ruby Rails Web Development
Ruby Rails Web DevelopmentRuby Rails Web Development
Ruby Rails Web DevelopmentFariha Tasnim
 
Ruby Rails Web Development
Ruby Rails Web DevelopmentRuby Rails Web Development
Ruby Rails Web DevelopmentFariha Tasnim
 
Sunserver Open Solaris
Sunserver Open SolarisSunserver Open Solaris
Sunserver Open Solarispankaj009
 
Ruby Rails Web Development
Ruby Rails Web DevelopmentRuby Rails Web Development
Ruby Rails Web DevelopmentSonia Simi
 
Ruby On Rails Seminar Basis Softexpo Feb2010
Ruby On Rails Seminar Basis Softexpo Feb2010Ruby On Rails Seminar Basis Softexpo Feb2010
Ruby On Rails Seminar Basis Softexpo Feb2010arif44
 
Ruby on Rails Development Services
Ruby on Rails Development ServicesRuby on Rails Development Services
Ruby on Rails Development ServicesSpritleSoftware
 
Instruments ruby on rails
Instruments ruby on railsInstruments ruby on rails
Instruments ruby on railspmashchak
 

Semelhante a RubyOnRails (20)

Ruby On Rails
Ruby On RailsRuby On Rails
Ruby On Rails
 
Soa With Ruby
Soa With RubySoa With Ruby
Soa With Ruby
 
Ror Seminar With agilebd.org on 23 Jan09
Ror Seminar With agilebd.org on 23 Jan09Ror Seminar With agilebd.org on 23 Jan09
Ror Seminar With agilebd.org on 23 Jan09
 
Ruby on rails backend development preferred choice for product owners
Ruby on rails backend development preferred choice for product ownersRuby on rails backend development preferred choice for product owners
Ruby on rails backend development preferred choice for product owners
 
Ruby Rails Web Development.pdf
Ruby Rails Web Development.pdfRuby Rails Web Development.pdf
Ruby Rails Web Development.pdf
 
Rails Concept
Rails ConceptRails Concept
Rails Concept
 
The Birth and Evolution of Ruby on Rails
The Birth and Evolution of Ruby on RailsThe Birth and Evolution of Ruby on Rails
The Birth and Evolution of Ruby on Rails
 
Ruby on rails for beginers
Ruby on rails for beginersRuby on rails for beginers
Ruby on rails for beginers
 
8 Common Ruby on Rails Development Mistakes to Avoid
8 Common Ruby on Rails Development Mistakes to Avoid8 Common Ruby on Rails Development Mistakes to Avoid
8 Common Ruby on Rails Development Mistakes to Avoid
 
Ruby on Rails : First Mile
Ruby on Rails : First MileRuby on Rails : First Mile
Ruby on Rails : First Mile
 
Top 20+ React Libraries Every JavaScript Professional Should Know in 2023
Top 20+ React Libraries Every JavaScript Professional Should Know in 2023Top 20+ React Libraries Every JavaScript Professional Should Know in 2023
Top 20+ React Libraries Every JavaScript Professional Should Know in 2023
 
Ruby On Rails
Ruby On RailsRuby On Rails
Ruby On Rails
 
8 awesome benefits of ruby on rails application development
8 awesome benefits of ruby on rails application development 8 awesome benefits of ruby on rails application development
8 awesome benefits of ruby on rails application development
 
Ruby Rails Web Development
Ruby Rails Web DevelopmentRuby Rails Web Development
Ruby Rails Web Development
 
Ruby Rails Web Development
Ruby Rails Web DevelopmentRuby Rails Web Development
Ruby Rails Web Development
 
Sunserver Open Solaris
Sunserver Open SolarisSunserver Open Solaris
Sunserver Open Solaris
 
Ruby Rails Web Development
Ruby Rails Web DevelopmentRuby Rails Web Development
Ruby Rails Web Development
 
Ruby On Rails Seminar Basis Softexpo Feb2010
Ruby On Rails Seminar Basis Softexpo Feb2010Ruby On Rails Seminar Basis Softexpo Feb2010
Ruby On Rails Seminar Basis Softexpo Feb2010
 
Ruby on Rails Development Services
Ruby on Rails Development ServicesRuby on Rails Development Services
Ruby on Rails Development Services
 
Instruments ruby on rails
Instruments ruby on railsInstruments ruby on rails
Instruments ruby on rails
 

Último

DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 

Último (20)

DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 

RubyOnRails

  • 1. . 09 The Ruby on Rails Web Framework Technical Report Anthony N. Ilukwe
  • 2. 3 Executive Summary Over the past three years, Ruby on Rails has become one of the most popular web application frameworks for developers. Ruby on Rails, shortly known as RoR, has redefined the way web applications can be created and deployed. One of its underlying principles, “Convention over configuration,” defines the development approach that emphasizes clean, concise code; making RoR applications easy to understand, code, test, and debug. RoR has a series of features such as code generation, security, validation, transaction, and testing; making it highly compact, portable, and tidy. It is also bundled with a web server, WEBRick; JavaScript library, Prototype; and AJAX library, script.aculo.us. These in-built libraries eliminate the need to import external tools, and make it easier for developers to integrate a wide variety of dynamic effects into their applications. RoR is developed with the Ruby programming language. A RoR application can be created in minutes. After installing the 3 main components: Ruby, Rails (framework), and MySQL on a machine; a series of simple commands can get a basic Ruby on Rails environment up and running.
  • 3. 4 Table of Contents Executive Summary............................................................................................................... 3 1. Introduction ...................................................................................................................... 5 2. Ruby on Rails..................................................................................................................... 5 2.1 Structure................................................................................................................................ 6 2.1.1 Environment .................................................................................................................... 6 2.1.2 MVC Pattern .................................................................................................................... 6 2.1.3 Libraries ........................................................................................................................... 7 2.1.4 Emphasis on convention.................................................................................................. 8 2.2 Features................................................................................................................................. 8 2.2.1 Built-in JavaScript libraries .............................................................................................. 8 2.2.2 Web Services ................................................................................................................... 8 2.2.3 Scaffolding ....................................................................................................................... 9 2.2.4 Built-in web server........................................................................................................... 9 2.2.5 Rake ................................................................................................................................. 9 3. Ruby: The Language........................................................................................................... 9 3.1 History & Description ............................................................................................................ 9 3.2 Advantages of Ruby............................................................................................................. 10 3.3 Syntax .................................................................................................................................. 10 3.4 Examples of Ruby Code....................................................................................................... 10 3.4.1 Simple Hello Word......................................................................................................... 10 3.4.2 Simple Loop ................................................................................................................... 10 3.4.3 Arrays............................................................................................................................. 11 3.4.4 String Methods .............................................................................................................. 12 4. Inside RoR Development.................................................................................................. 12 4.1 The development environment .......................................................................................... 12 4.1.1 Creating a simple application ........................................................................................ 12 4.1.1.1 Model...................................................................................................................... 14 4.1.1.2 View......................................................................................................................... 15 4.1.1.3 Controller................................................................................................................ 15 5. Conclusion....................................................................................................................... 16 6. References....................................................................................................................... 17
  • 4. 5 1. Introduction Since the early 90’s, several software frameworks have been created for the purpose of developing database and interactive, or action-driven websites, or web applications. There are a number of different web application frameworks, from which developers have a wide variety to choose. These web application frameworks vary according to their scripting languages, back-end server compatibility, configuration, structure, built-in functionality, and supported frameworks. However, most web application frameworks have similar features such as: • Authentication • Databases • HTML or Layout directory • Libraries • Computer-to-computer interaction Popular web application frameworks include: ASP.NET, Echo, JQuery, Scheme, ColdFusion, Python, Perl, PHP, and Ruby. This report will discuss Ruby On Rails as a Ruby web application framework. It will detail the main components, features, and structure of this framework, as well as highlighting why it is being embraced by a growing number of Web 2.0 developers. 2. Ruby On Rails Ruby On Rails (RoR) is one of a growing number of free “Open Source” web application frameworks available. The source code for these “Open Source” frameworks is available for developers to tweak, and as a result the collaborative effort is beneficial to the entire community of developers and users. RoR was first released by a team led by Danish programmer David Heinemeier-Hansson in 2004, and several versions have been released ever since.
  • 5. 6 In addition to its relatively compact structure and built-in features, one of the main distinctions of RoR is the “Convention over Configuration” philosophy that defines the underlying development techniques. This will be discussed in the next section. 2.1. Structure 2.1.1. Environment The RoR environment runs on web servers such as WEBrick, Mongrel, and Apache. Apache is the most widely used of the aforementioned, although WEBRick and Mongrel were initially used to run RoR. Popular open-source relational database management system MySQL is most commonly used to provide database services for RoR applications, as it is also built for smooth functionality with Apache web servers. Other database systems such as Oracle and SQLite can also be used. 2.1.2. MVC Pattern RoR applications are structured according to the MVC (Model View Controller) software engineering pattern. This structural pattern ensures that the interface, application, and database files are separated in a manner that especially suites agile application development. When a RoR application development project is initiated, the application folder is created with a subfolder for each of these components (model, view, and controller). 2.1.3. Libraries There are several libraries that merge to form the RoR framework. These libraries provide different functions in the general framework structure, such as web services, database-mapping and mail services. Some of these libraries include: • ActivePack • ActiveResource
  • 6. 7 • ActiveRecord • ActiveMailer • ActiveSupport Figure 1: Ruby On Rails Architecture 2.1.4. Emphasis on Convention RoR follows a strict naming convention, which when correctly used, easily identifies various components in an application, from fields to objects and variables. Database tables have to be given names in plural, as they represent objects. And certain table attributes have to follow a strict pattern. For example, a database table would be called “animals,” representing an Animal object in the system, while the foreign key column would be named “animal_id.”
  • 7. 8 The creators of RoR wanted a web framework that reduced a lot of the code redundancy often associated with other frameworks like PHP and ASP. This convention leads to concise, clever, and arguably clean lines of code that can be easily debugged and modified. In a subsequent section, this will be discussed in more detail. 2.2. Features 2.2.1. Built-in JavaScript Libraries RoR is shipped with JavaScript library or framework Prototype, which offers a variety of client-side dynamic effects for web applications. This bundling makes it easy for developers to use Javascript commands and scripting within Rails applications, without having to import – the likely case when developing with most other web frameworks. Another Javascript/AJAX library, script.aculo.us, is also bundled with RoR. Like Prototype, Script.aculo.us is useful for visual effects, and it additionally provides a range of user interface elements as well as more dynamic effects. 2.2.2. Web Services RoR uses the web services SOAP and RESTful to support its computer-to-computer network interaction. 2.2.3. Scaffolding One of the handiest features that RoR has to offer is scaffolding. This is a technique through which code is generated for an application by simply entering the corresponding commands. For example, the command line entry scaffold :model_name will generate a series of Ruby files that server as a bridge between the controller and the model (database).
  • 8. 9 2.2.4. Built-in Web Server Ruby On Rails contains a built-in web server called WEBrick. This built-in web server does not necessarily have to be run with a local Rails application, but it serves the purpose of creating a complete development environment within the package. 2.2.5. Rake Rake is a feature than enables developers to use simple pre-built commands to perform tasks like database migrations, backups, and cache generation. This is one of the handiest features of Ruby On Rails, as it enables developers to use pre-made rake commands, and also to create their own; hence using less code and saving time. For example, if an update is made to a database schema, typing rake db:migrate will instantly synchronize all the model files related to the updated schema. More examples of rake will be shown later. 3. Ruby: The Language As stated earlier, the Ruby On Rails framework is based on the Ruby programming language. The next subsections give a detailed overview of Ruby. 3.1. History & Description Ruby was created by Japanese programmer Yukihiro Matsumoto with the goal of a cross- platform, object-oriented programming language that also incorporates procedural programming techniques in addition to practices such as automatic garbage collection, memory management and code generation. Ruby was initially developed with C, and has syntax that is similar to that of Perl, Python, and SmallTalk. In another section, I will substantiate more on Ruby grammar. Unlike Java and C++, Ruby instance variables are always private and cannot be accessed without accessor methods. These Ruby accessor methods are a lot simpler than in Java, and some examples are included in Section 3.4.
  • 9. 10 3.2. Advantages of Ruby Over Other Languages • Portability • Ability to overload operators • Auto garbage-collection • Flexibility • Exception handling • Large standard library • Iterators and closures 3.3. Syntax One of Ruby’s distinctive features is the somewhat intrinsic detail involved with the grammar and syntax. Some of the major syntax rules are listed below: • Line breaks are used to signify the end of a statement • Instead of brackets, keywords are used to signify class and method definitions • Local variables must always begin with lower case characters • Constants must always begin with upper case characters • Instance variables start with @ • Global variables start with $ • Comment blocks start with # 3.4. Examples of Ruby Code: Methods and Classes 3.4.1. Simple Hello Word print "Hello world!" This simply prints out the text “Hello world!” 3.4.2. Simple Loop #!/usr/bin/Ruby for ss in 1...5 print ss, " Hellon"; end
  • 10. 11 Prints: Hello Hello Hello Hello Hello 3.1.1. A More Advanced Loop puts "@@@@@" ss = 5 while ss > 0 puts ss ss -= 2 if ss == 1 ss += 5 end Prints out: @@@@@ 5 3 6 4 2 3.4.3. Arrays Here, I created an array and used the .each methods to loop through: cars = ["Honda", "Nissan", "Toyota", "GMC", "Ford", "Chrysler"] cars.each { |i| print i, "n"} Prints: Honda Nissan Toyota GMC
  • 11. 12 Ford Chrysler 3.4.4. String Methods Below are examples of simple String operations, for a String defined as “Yes we can” newstring = "Yes we can" #declare variable newstring.capitalize # prints "Yes We Can" newstring.downcase # prints "yes we can" newstring.reverse # prints "nac ew sey" As I’ve shown in this section, Ruby is a very easy language to learn, and the similarity to common English makes the syntax less of a burden for beginners. 4. Inside Ruby On Rails Development This section will examine the creation of a basic Ruby On Rails application, as well as an inside look at the Ruby On Rails application environment. 4.1. The development environment 4.1.1. Creating a simple application After installing Ruby, Rails, and MySQL database, running the following terminal command inside the development directory will create an empty Ruby On Rails application called “Apollo.” rails apollo As seen in the next graphic, this command creates the entire application directory structure and a series of Ruby, HTML, and database files.
  • 12. 13 Figure 2: Application directories and files being created with the “rails” command
  • 13. 14 Figure 3: Directory structure of the empty Apollo application. 4.1.1.1. Model The model folder consists of Ruby class files that define every domain (entity) in the application model. That is, for each table on the database, there is a corresponding class in this folder. The class defines the attributes (columns) of each domain.
  • 14. 15 4.1.1.2. View The view folder contains the interface files through which the application is viewed by users. These files are mostly HTML files that contain slices of RHTML (embedded Ruby code) to drive the web page’s dynamics. 4.1.1.3. Controller This folder consists of Ruby classes that communicate with the application data, based on user interaction with the view layer. These Ruby files perform a variety of functions in order to ensure that data is being fetched from the database tables and displayed on the interface, when necessary. Figure 4: Model View Controller Architecture
  • 15. 16 5. Conclusion The ease and simplicity of Ruby On Rails makes it possible for an individual to handle a web development project that would have conventionally been done by a team. As web development reaches newer and greater heights; with unending potential for speed, efficiency, and dynamism, Ruby On Rails will become a staple for some of the great web applications yet to come.
  • 16. 17 References Corbridge, R., Introducing Ruby On Rails, Software Developer. http://www.softwaredeveloper.com/features/intro-to-Ruby-on-rails-part-two- 043007. 2007. Introducing Ruby On Rails. The Workshop. http://www.eclips3media.com/workshop/2007/06/28/introducing-Ruby-on-rails. 2007. Ruby On Rails. (2009, January 12). In Wikipedia, the free encyclopedia. Retrieved January 17, 2009, from http://en.wikipedia.org/wiki/Ruby_on_Rails Ruby (Programming Language). (2009, January 3). In Wikipedia, the free encyclopedia. Retrieved January 8, 2009, from http://en.wikipedia.org/wiki/Ruby_(programming_language)