SlideShare a Scribd company logo
1 of 24
Ruby on Rails Server-side web development  VladStoian Victor Porof
What we’ll talk about What is Ruby on Rails? A brief history MVC architecture in a nutshell Distinctive framework features Why Ruby? Why Rails? Demo
What is RoR? Open Source Abstraction providing generic server-side functionality Used for web application development It’s a framework for the Ruby language ..so don’t confuse it with plain Ruby!
A brief history Originates in David Heinemeier Hansson’s work First released in July 2004 Apple ships RoR with Mac OS X Leopard since 2007 Major new developments with v2.3 in 2009 Templates Generate skeleton applications Custom gems and configurations Latest: v3.0.5, 27 February 2011
MVC architecture RoR is based on the Model-View-Controller design It’s an architectural development pattern Widely used in many other frameworks: Oracle Application Framework, Cocoon, JSF (Java) ASP.NET (C#) SproutCore, JavascriptMVC (Javascript) Django, Pylons (Python) CakePHP(PHP) PureMVC (many languages)
MVC on Rails Models are Ruby classes, used to store and validate data Handles migrations They talk to databases MySQL SQLite PostgreSQL NoSQL MongoDB Cassandra “Chubby guy in the back room” crunching the numbers
Model snippet class Person < ActiveRecord::Base validates_presence_of :name has_many :wifes end Person.create(:name => ”Muhammad Ali”).valid? # => true Person.create(:name => nil).valid? # => false
Migration snippet class AddReceiveNewsletterToUsers < ActiveRecord::Migration defself.up change_table :users do |t| t.boolean :receive_newsletter, :default => false     end User.update_all ["receive_newsletter = ?", true]   end defself.down remove_column :users, :receive_newsletter   end end
MVC on Rails What the user sees HTML, CSS, XML, Javascript (jQuery) JSON, RSS, Atom Automatically generated “view-puppets” Visual representation of data Does not have direct access to the model! It shouldn’t do lots of processing or calculation
View snippet  <!-- app/views/items/new.rhtml -->   <%= form_tag :action => “create” %>    Name: <%= text_field“item”, “name”%><br/> Email: <%= text_field“item”, ”email”%><br/>   Password: <%= hidden_field “item”, “password”%><br/>    <%= submit_tag %>   <%= end_form_tag %>
MVC on Rails Gateway between the model and the view Handles user requests Does parsing and data submissions Takes care of sessions, cookies Works out what data to show and what views to render ”The best controller: it gives orders without knowing  (or caring) how it gets done”
Controller snippet classItemsController < ApplicationController     def edit       @item = Item.find(params[:id]) ifrequest.post?          @item.update_attributes(params[:item]) redirect_to :action => 'edit', :id => @item.id       end     end   end
MVC on Rails To summarize: Keep your view code skinny Keep your controller code skinny The fatness is in the model
Framework features Code generators Awesome built-in functions => rapid development Tons of “gems” to choose from Cross-platform compatibility Automated operation (CRUD) Create, Retrieve, Automate and Delete Simplified testing (Rake script)
Code generator snippet #model generator (general) ruby script/generate model model_name (v2.3) rails generate model model_name (v3) #model generator (example) rails generate model user name:stringhashed_password:string #controller generator (general) ruby script/generate controller controller_namemethod_name(s)  (v2.3) rails generate controller controller_namemethod_name(s) (v3) #controller generator (example) rails generate controller store index
RoR servers Mongrel Webbrick Thin Apache (mod_passanger) ..so it’s very scalable!
Famous projects on Rails Twitter (microblogging) Crunchbase (companies database) BaseCamp (project management) Hulu (online tv) Yellowpages.com (phone database) Xing (business network)
Why Ruby? Interpreted language => greater flexibility Provides JIT (just in time compilation) Garbage collection Able to generate code on the fly Cleaner syntax (no more “Verbose verbose is too verbose for verbose”) Many implementations: Jruby, IronRuby, Rubinius (Ruby & C++), MacRuby (ObjC)
Why Rails? Based on Ruby Easy to implement CGI scripts Rapid web-application development Designed to make programming work easier Less coding, more functionality Thousands of plugins Don’t reinvent the wheel
Creating a blog with
Beginners' guide to Ruby on Rails
Beginners' guide to Ruby on Rails

More Related Content

What's hot

Ruby on Rails Security
Ruby on Rails SecurityRuby on Rails Security
Ruby on Rails Security
amiable_indian
 
Intro to node.js - Ran Mizrahi (28/8/14)
Intro to node.js - Ran Mizrahi (28/8/14)Intro to node.js - Ran Mizrahi (28/8/14)
Intro to node.js - Ran Mizrahi (28/8/14)
Ran Mizrahi
 
An Introduction to JavaScript
An Introduction to JavaScriptAn Introduction to JavaScript
An Introduction to JavaScript
tonyh1
 

What's hot (20)

Ruby on Rails Security
Ruby on Rails SecurityRuby on Rails Security
Ruby on Rails Security
 
Ruby on Rails: Coding Guideline
Ruby on Rails: Coding GuidelineRuby on Rails: Coding Guideline
Ruby on Rails: Coding Guideline
 
Spring MVC 3.0 Framework
Spring MVC 3.0 FrameworkSpring MVC 3.0 Framework
Spring MVC 3.0 Framework
 
SpringMVC
SpringMVCSpringMVC
SpringMVC
 
WEB TECHNOLOGIES JavaScript
WEB TECHNOLOGIES JavaScriptWEB TECHNOLOGIES JavaScript
WEB TECHNOLOGIES JavaScript
 
Wt unit 6 ppts web services
Wt unit 6 ppts web servicesWt unit 6 ppts web services
Wt unit 6 ppts web services
 
Jsp
JspJsp
Jsp
 
Introduction to JavaScript
Introduction to JavaScriptIntroduction to JavaScript
Introduction to JavaScript
 
C# Advanced L09-HTML5+ASP
C# Advanced L09-HTML5+ASPC# Advanced L09-HTML5+ASP
C# Advanced L09-HTML5+ASP
 
JavaScript 101
JavaScript 101JavaScript 101
JavaScript 101
 
JavaScript - Chapter 3 - Introduction
 JavaScript - Chapter 3 - Introduction JavaScript - Chapter 3 - Introduction
JavaScript - Chapter 3 - Introduction
 
Introduction to JavaScript Programming
Introduction to JavaScript ProgrammingIntroduction to JavaScript Programming
Introduction to JavaScript Programming
 
AngularJS Basics
AngularJS BasicsAngularJS Basics
AngularJS Basics
 
Workshop 2: JavaScript Design Patterns
Workshop 2: JavaScript Design PatternsWorkshop 2: JavaScript Design Patterns
Workshop 2: JavaScript Design Patterns
 
Struts N E W
Struts N E WStruts N E W
Struts N E W
 
Internet and Web Technology (CLASS-14) [JSP] | NIC/NIELIT Web Technology
Internet and Web Technology (CLASS-14) [JSP] | NIC/NIELIT Web Technology Internet and Web Technology (CLASS-14) [JSP] | NIC/NIELIT Web Technology
Internet and Web Technology (CLASS-14) [JSP] | NIC/NIELIT Web Technology
 
Internet and Web Technology (CLASS-10) [Node.js] | NIC/NIELIT Web Technology
Internet and Web Technology (CLASS-10) [Node.js] | NIC/NIELIT Web Technology Internet and Web Technology (CLASS-10) [Node.js] | NIC/NIELIT Web Technology
Internet and Web Technology (CLASS-10) [Node.js] | NIC/NIELIT Web Technology
 
Intro to node.js - Ran Mizrahi (28/8/14)
Intro to node.js - Ran Mizrahi (28/8/14)Intro to node.js - Ran Mizrahi (28/8/14)
Intro to node.js - Ran Mizrahi (28/8/14)
 
An Introduction to JavaScript
An Introduction to JavaScriptAn Introduction to JavaScript
An Introduction to JavaScript
 
AngularJS Introduction
AngularJS IntroductionAngularJS Introduction
AngularJS Introduction
 

Similar to Beginners' guide to Ruby on Rails

Server-side Web development via Ruby on Rails
Server-side Web development via Ruby on RailsServer-side Web development via Ruby on Rails
Server-side Web development via Ruby on Rails
g3ppy
 
Deview 2013 mobile browser internals and trends_20131022
Deview 2013 mobile browser internals and trends_20131022Deview 2013 mobile browser internals and trends_20131022
Deview 2013 mobile browser internals and trends_20131022
NAVER D2
 

Similar to Beginners' guide to Ruby on Rails (20)

Server-side Web development via Ruby on Rails
Server-side Web development via Ruby on RailsServer-side Web development via Ruby on Rails
Server-side Web development via Ruby on Rails
 
Intro to .NET for Government Developers
Intro to .NET for Government DevelopersIntro to .NET for Government Developers
Intro to .NET for Government Developers
 
Ruby Rails Web Development
Ruby Rails Web DevelopmentRuby Rails Web Development
Ruby Rails Web Development
 
Asp.Net MVC3 - Basics
Asp.Net MVC3 - BasicsAsp.Net MVC3 - Basics
Asp.Net MVC3 - Basics
 
MSc Enterprise Systems Development Guest Lecture at UniS (2/12/09)
MSc Enterprise Systems Development Guest Lecture at UniS (2/12/09)MSc Enterprise Systems Development Guest Lecture at UniS (2/12/09)
MSc Enterprise Systems Development Guest Lecture at UniS (2/12/09)
 
ASP.net MVC Introduction Wikilogia (nov 2014)
ASP.net MVC Introduction Wikilogia (nov 2014)ASP.net MVC Introduction Wikilogia (nov 2014)
ASP.net MVC Introduction Wikilogia (nov 2014)
 
Laravel overview
Laravel overviewLaravel overview
Laravel overview
 
MVC - Introduction
MVC - IntroductionMVC - Introduction
MVC - Introduction
 
CG_CS25010_Lecture
CG_CS25010_LectureCG_CS25010_Lecture
CG_CS25010_Lecture
 
ruby on rails development company in india
ruby on rails development company in indiaruby on rails development company in india
ruby on rails development company in india
 
Modern ASP.NET Webskills
Modern ASP.NET WebskillsModern ASP.NET Webskills
Modern ASP.NET Webskills
 
Aspose pdf
Aspose pdfAspose pdf
Aspose pdf
 
Deview 2013 mobile browser internals and trends_20131022
Deview 2013 mobile browser internals and trends_20131022Deview 2013 mobile browser internals and trends_20131022
Deview 2013 mobile browser internals and trends_20131022
 
Asp.net mvc presentation by Nitin Sawant
Asp.net mvc presentation by Nitin SawantAsp.net mvc presentation by Nitin Sawant
Asp.net mvc presentation by Nitin Sawant
 
Web Development Today
Web Development TodayWeb Development Today
Web Development Today
 
Asp.net mvc 5 course module 1 overview
Asp.net mvc 5 course   module 1 overviewAsp.net mvc 5 course   module 1 overview
Asp.net mvc 5 course module 1 overview
 
The web as it should be
The web as it should beThe web as it should be
The web as it should be
 
Ruby on rails for beginers
Ruby on rails for beginersRuby on rails for beginers
Ruby on rails for beginers
 
Spring tutorials
Spring tutorialsSpring tutorials
Spring tutorials
 
Ruby On Rails - Rochester K Linux User Group
Ruby On Rails - Rochester K Linux User GroupRuby On Rails - Rochester K Linux User Group
Ruby On Rails - Rochester K Linux User Group
 

More from Victor Porof

More from Victor Porof (11)

Firefox WebGL developer tools
Firefox WebGL developer toolsFirefox WebGL developer tools
Firefox WebGL developer tools
 
Firefox developer tools
Firefox developer toolsFirefox developer tools
Firefox developer tools
 
Js in the open
Js in the openJs in the open
Js in the open
 
Processing.js vs. three.js
Processing.js vs. three.jsProcessing.js vs. three.js
Processing.js vs. three.js
 
Javascript, Do you speak it!
Javascript, Do you speak it!Javascript, Do you speak it!
Javascript, Do you speak it!
 
Cityquest - Developing games for the mobile devices
Cityquest - Developing games for the mobile devicesCityquest - Developing games for the mobile devices
Cityquest - Developing games for the mobile devices
 
Web3D - Semantic standards, WebGL, HCI
Web3D - Semantic standards, WebGL, HCIWeb3D - Semantic standards, WebGL, HCI
Web3D - Semantic standards, WebGL, HCI
 
Chameleon game engine
Chameleon game engineChameleon game engine
Chameleon game engine
 
Developing web apps using Java and the Play framework
Developing web apps using Java and the Play frameworkDeveloping web apps using Java and the Play framework
Developing web apps using Java and the Play framework
 
Introduction to the XNA framework
Introduction to the XNA frameworkIntroduction to the XNA framework
Introduction to the XNA framework
 
Introduction to 3D and shaders
Introduction to 3D and shadersIntroduction to 3D and shaders
Introduction to 3D and shaders
 

Recently uploaded

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Recently uploaded (20)

Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
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
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
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
 
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
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 

Beginners' guide to Ruby on Rails

  • 1. Ruby on Rails Server-side web development VladStoian Victor Porof
  • 2. What we’ll talk about What is Ruby on Rails? A brief history MVC architecture in a nutshell Distinctive framework features Why Ruby? Why Rails? Demo
  • 3. What is RoR? Open Source Abstraction providing generic server-side functionality Used for web application development It’s a framework for the Ruby language ..so don’t confuse it with plain Ruby!
  • 4. A brief history Originates in David Heinemeier Hansson’s work First released in July 2004 Apple ships RoR with Mac OS X Leopard since 2007 Major new developments with v2.3 in 2009 Templates Generate skeleton applications Custom gems and configurations Latest: v3.0.5, 27 February 2011
  • 5. MVC architecture RoR is based on the Model-View-Controller design It’s an architectural development pattern Widely used in many other frameworks: Oracle Application Framework, Cocoon, JSF (Java) ASP.NET (C#) SproutCore, JavascriptMVC (Javascript) Django, Pylons (Python) CakePHP(PHP) PureMVC (many languages)
  • 6.
  • 7. MVC on Rails Models are Ruby classes, used to store and validate data Handles migrations They talk to databases MySQL SQLite PostgreSQL NoSQL MongoDB Cassandra “Chubby guy in the back room” crunching the numbers
  • 8. Model snippet class Person < ActiveRecord::Base validates_presence_of :name has_many :wifes end Person.create(:name => ”Muhammad Ali”).valid? # => true Person.create(:name => nil).valid? # => false
  • 9. Migration snippet class AddReceiveNewsletterToUsers < ActiveRecord::Migration defself.up change_table :users do |t| t.boolean :receive_newsletter, :default => false end User.update_all ["receive_newsletter = ?", true] end defself.down remove_column :users, :receive_newsletter end end
  • 10. MVC on Rails What the user sees HTML, CSS, XML, Javascript (jQuery) JSON, RSS, Atom Automatically generated “view-puppets” Visual representation of data Does not have direct access to the model! It shouldn’t do lots of processing or calculation
  • 11. View snippet <!-- app/views/items/new.rhtml --> <%= form_tag :action => “create” %> Name: <%= text_field“item”, “name”%><br/> Email: <%= text_field“item”, ”email”%><br/> Password: <%= hidden_field “item”, “password”%><br/> <%= submit_tag %> <%= end_form_tag %>
  • 12. MVC on Rails Gateway between the model and the view Handles user requests Does parsing and data submissions Takes care of sessions, cookies Works out what data to show and what views to render ”The best controller: it gives orders without knowing (or caring) how it gets done”
  • 13. Controller snippet classItemsController < ApplicationController def edit @item = Item.find(params[:id]) ifrequest.post? @item.update_attributes(params[:item]) redirect_to :action => 'edit', :id => @item.id end end end
  • 14. MVC on Rails To summarize: Keep your view code skinny Keep your controller code skinny The fatness is in the model
  • 15. Framework features Code generators Awesome built-in functions => rapid development Tons of “gems” to choose from Cross-platform compatibility Automated operation (CRUD) Create, Retrieve, Automate and Delete Simplified testing (Rake script)
  • 16. Code generator snippet #model generator (general) ruby script/generate model model_name (v2.3) rails generate model model_name (v3) #model generator (example) rails generate model user name:stringhashed_password:string #controller generator (general) ruby script/generate controller controller_namemethod_name(s) (v2.3) rails generate controller controller_namemethod_name(s) (v3) #controller generator (example) rails generate controller store index
  • 17. RoR servers Mongrel Webbrick Thin Apache (mod_passanger) ..so it’s very scalable!
  • 18. Famous projects on Rails Twitter (microblogging) Crunchbase (companies database) BaseCamp (project management) Hulu (online tv) Yellowpages.com (phone database) Xing (business network)
  • 19. Why Ruby? Interpreted language => greater flexibility Provides JIT (just in time compilation) Garbage collection Able to generate code on the fly Cleaner syntax (no more “Verbose verbose is too verbose for verbose”) Many implementations: Jruby, IronRuby, Rubinius (Ruby & C++), MacRuby (ObjC)
  • 20. Why Rails? Based on Ruby Easy to implement CGI scripts Rapid web-application development Designed to make programming work easier Less coding, more functionality Thousands of plugins Don’t reinvent the wheel
  • 21.