SlideShare ist ein Scribd-Unternehmen logo
1 von 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)

Weitere ähnliche Inhalte

Ähnlich wie 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
 

Ähnlich wie 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
 

Kürzlich hochgeladen

Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 

Kürzlich hochgeladen (20)

Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 

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)