SlideShare a Scribd company logo
Introduction to Ruby on Rails  Welcome to the puzzle….it’s a fun ride! By Steve Keener
Terms you will hear Full stack Active Record Object Relational Model (ORM) MVC Gems RHTML Migration SVN
What is RoR? It’s the next best thing to sliced bread? It’s the silver bullet to fix our project? It’s magic? None of these things.  It’s a tool.  But it was conceived as a highly productive tool where DRY is paramount.  Don’t Repeat Yourself.
Things you will need Ruby (Language) Rails (Framework in Ruby) Database  Start here:  www.rubyonrails.org/down You can download Instant Rails (Windows only).  It contains Ruby, Rails, and MySQL for trying out the RoR world. You would use the command line and text editors to create applications.
Available Development IDEs RadRails – Eclipse-based, integrated generators & servers. http://www.radrails.org/ TextMate – Mac oriented http://www.macromates.com/ I use RadRails.  Downside is that code generators are still command line.  But  that’s a minor drawback.
Source Code Repositories CVS – Doesn’t seem to be the preferred repository.  Haven’t found an integrated delivery system.  I used simple Ant scripts to build my delivery processes. SVN – Preferred repository and is integrated with Capistrano. (Rails version of application delivery systems.)
After that… The first place to start the journey is by reading the article “Rolling with Ruby on Rails” by Curt Hibbs. http://www.onlamp.com/pub/a/onlamp/2005/01/20/rails.html
Then what? You should pick up two books: Agile Web Development with Rails  (Excellent) Rails Recipes  (Great for finding specific functional modules you might need and having them running in an hour.)
Other resources Rails online API  http://api.rubyonrails.org/ Ruby Forums http://www.ruby-forum.com/user/login RubyForge http://rubyforge.org/
On to Rails… Object Relational Mapping: ActiveRecord Like Java’s Hibernate (but simpler) Takes away a lot of the drudgery associated with web applications. (Create, Retrieve, Update, and Delete functions.)
Full Stack J2EE Rails Webrick or  Mongrel DispatchServlet RHTML ActionController ActiveRecord Database Layer Database Layer Hibernate Action Action Form JSP ActionServlet Tomcat Servlet Container Yes…they are fairly comparable…. Note:  Found diagram on web
Or another way to put it
Or maybe this way…
Rails vs J2EE Both have a learning curve RAILS has the edge in productivity by a significant margin. J2EE currently has an edge in scalability.  If it’s a client facing system for millions of concurrent users – use J2EE.  If it’s an internal web application, definitely take a look at this technology as a possible way of shortcutting the long development time for a J2EE web app.
Can’t afford the time to learn a new framework!!!  I needed a few screens to manage some dev data.  Was investigating several different technologies to see what would best serve the need and timeframe.  (J2EE, Hibernate, JSF, Rails, etc) Day 1 - Picked up a Ruby On Rails book, read a few articles, started experimenting. Day 2 - Stated building a few screens, relying on dynamic scaffolding for basic CRUD functionality Day 3 - Began replacing scaffold screens with better looking ones by hand. Day 4 – Started adding layouts, CCS, and some AJAX functionality to make application a bit nicer. Day 5 – Began investigating Models, Migrations, and RJS templates to enhance productivity.  5 days from start, over 50 screens produced, far more functionality than I had been planning, demos to multiple managers, and more than a few headaches.  It’s not perfect, but is certainly a useful tool.  (NOT A SILVER BULLET!!!!!!)
Database  New term – Migration: A powerful and flexible tool for managing database changes Allows table, index, and data creation scripts to be run in multiple environments with a  very simple syntax. Need to revert back to a previous DB version to work on a bug?  1 command.  Then refresh it back to the current dev version?  1 command.
Example Migration class  CreateMenuitems < ActiveRecord::Migration def  self.up # Create the Menuitems table.  The ID field does not need to be specified – automagically created.  create_table  :menuitems   do  |t| t.column  :href ,  :string ,  :limit  =>  75 t.column  :title ,  :string ,  :limit  =>  75 t.column  :desc ,  :string ,  :limit  =>  75 t.column  :leadtag ,  :string ,  :limit  =>  25 t.column  :endtag ,  :string ,  :limit  =>  25 end item = Menuitem.create( :href  => &quot;/menu/zero_dollars.html&quot;,    :title  => &quot;Zero dollar page1&quot;,    :desc  => &quot;Zero dollar ads1&quot;,    :leadtag  => &quot;<li>&quot;,    :endtag  => &quot;</li>&quot;) item.save   end def  self.down drop_table  :menuitems end end
MVC Model / View / Controller  Model  – Used for persistence and relationships View  – Used for displaying the data Controller  – The logic of the application
Example Model class  Node < ActiveRecord::Base end Yes….that’s it.  Rails queries the database and determines the datatypes and fields for you.  You can add data relationships, data validations to the model later.  This is enough to get the scaffold screens up and running.
Example View (With AJAX functionality thrown in) <h1>Listing nodes</h1> <table> <tr> <th>Desc</th> <th>Create date</th> <th>Status</th> </tr> <%  @nodes . each   do  |n| %> <tr> <td> <%=  @node  = n; in_place_editor_field  :node ,  :desc , {}, { :url  => '/node/node_update_desc/' <<  @node .id.to_s,  :rows  =>  1 ,  :cancelLink  => 'false'} %>   </td> <td width=&quot;50%&quot; align=&quot;center&quot;><%= n.created_at %></td> <td width=&quot;50%&quot; align=&quot;center&quot;><%= n.status %></td> </tr> <%  end  %>  </table>
Example Controller def  list @nodes  = Node.find( :all ) end - Uses the ActiveRecord Object Relational Mapping capabilities to pull all of the nodes in the Nodes table.  No SQL written here to cause problems.
Rails/Ruby conventions Ruby Gems – Like Java Jar files.  Packages that can be installed.  Taken one step further – simple installation methodologies. Convention over configuration.  Use the “Rails Way”.  The framework is designed to make development fast and easy. RHTML -  HTML files with embedded Ruby/Rails code.  Preprocessed into HTML
Resources Rails API http://api.rubyonrails.org/ CSS Menus http://www.cssplay.co.uk/menus/index.html Live DataGrid http://unspace.ca/discover/datagrid/
More… Subversion http://subversion.tigris.org/ Data Relationships diagram http://mboffin.com/stuff/ruby-on-rails-data-relationships.png Cheatsheets http://www.rubyonrailsblog.com/files/RoRblog-CheatSheet.pdf
Cheatsheets Migration http://garrettsnider.backpackit.com/pub/367902 Rails http://www.rubyonrailsblog.com/files/RoRblog-CheatSheet.pdf Webservices on Rails http://manuals.rubyonrails.com/read/book/10 WebCast How-To site http://peepcode.com/
Summary It’s an evolving toolset.  DRY leads to fewer lines of code.  Less code should mean less chances for bugs. Still requires normal analysis to be done on a project.  But you can react far quicker to changes in requirements. A great tool for your toolbox.

More Related Content

PPT
The basic process of Ruby on Rails
PPTX
Java spring mysql without hibernate(2) (1)
PPTX
Web scraping with BeautifulSoup, LXML, RegEx and Scrapy
PPTX
Optimizing Content Managed Rich JavaScript Apps
PDF
Communication tool & Environment for Remote Worker
PDF
Event streams all the way down
PDF
Beyond Fault Tolerance with Actor Programming
PDF
Angularjs & REST
The basic process of Ruby on Rails
Java spring mysql without hibernate(2) (1)
Web scraping with BeautifulSoup, LXML, RegEx and Scrapy
Optimizing Content Managed Rich JavaScript Apps
Communication tool & Environment for Remote Worker
Event streams all the way down
Beyond Fault Tolerance with Actor Programming
Angularjs & REST

What's hot (20)

PDF
Rails 5 – most effective features for apps upgradation
PDF
Frontend as a first class citizen
PDF
Automated Duplicate Content Consolidation with Google Cloud Functions
PDF
All girlhacknight intro to rails
PDF
The Evolution of Airbnb's Frontend
PDF
Rails api + JS app
PDF
EmberCLI Rails: An Integration Love Story.
PDF
Ruby performance - The low hanging fruit
PDF
API Days Australia - Automatic Testing of (RESTful) API Documentation
PDF
"Frameworks in 2015" Андрей Листочкин
PPT
Rails review
PDF
Going Headless with Craft CMS 3.3
PDF
Meetup dpjs react_api
PDF
Vue.js basics
PDF
AppBuilder Tour
PPTX
PPT
Web Os Hands On
PDF
AWS Lambda Function with Kotlin
PPTX
Kotlin db migration tool
PPTX
Going Serverless with AWS Lambda at ReportGarden
Rails 5 – most effective features for apps upgradation
Frontend as a first class citizen
Automated Duplicate Content Consolidation with Google Cloud Functions
All girlhacknight intro to rails
The Evolution of Airbnb's Frontend
Rails api + JS app
EmberCLI Rails: An Integration Love Story.
Ruby performance - The low hanging fruit
API Days Australia - Automatic Testing of (RESTful) API Documentation
"Frameworks in 2015" Андрей Листочкин
Rails review
Going Headless with Craft CMS 3.3
Meetup dpjs react_api
Vue.js basics
AppBuilder Tour
Web Os Hands On
AWS Lambda Function with Kotlin
Kotlin db migration tool
Going Serverless with AWS Lambda at ReportGarden
Ad

Similar to Introduction To Ruby On Rails (20)

PPT
Jasig Rubyon Rails
PPT
Ruby On Rails Tutorial
PPT
Ruby On Rails Siddhesh
KEY
Supa fast Ruby + Rails
PPT
Ruby on Rails introduction
PDF
Ruby On Rails
PPT
Ruby on rails
ODP
Practical catalyst
PDF
RoR 101: Session 2
PPT
Viridians on Rails
PPTX
Ruby on rails for beginers
PDF
RoR (Ruby on Rails)
PDF
Introduction to Rails - presented by Arman Ortega
PDF
Ruby on Rails Presentation
PDF
Crash Course HTML/Rails Slides
PPT
Ruby On Rails
PDF
Create a new project in ROR
PDF
Introduction to Ruby on Rails
PPTX
Intro to Rails and MVC
PPT
An Introduction to Ruby on Rails 20100506
Jasig Rubyon Rails
Ruby On Rails Tutorial
Ruby On Rails Siddhesh
Supa fast Ruby + Rails
Ruby on Rails introduction
Ruby On Rails
Ruby on rails
Practical catalyst
RoR 101: Session 2
Viridians on Rails
Ruby on rails for beginers
RoR (Ruby on Rails)
Introduction to Rails - presented by Arman Ortega
Ruby on Rails Presentation
Crash Course HTML/Rails Slides
Ruby On Rails
Create a new project in ROR
Introduction to Ruby on Rails
Intro to Rails and MVC
An Introduction to Ruby on Rails 20100506
Ad

Recently uploaded (20)

PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Modernizing your data center with Dell and AMD
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PPTX
Cloud computing and distributed systems.
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Empathic Computing: Creating Shared Understanding
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Encapsulation theory and applications.pdf
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Review of recent advances in non-invasive hemoglobin estimation
PPTX
A Presentation on Artificial Intelligence
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
Unlocking AI with Model Context Protocol (MCP)
NewMind AI Weekly Chronicles - August'25 Week I
Modernizing your data center with Dell and AMD
Reach Out and Touch Someone: Haptics and Empathic Computing
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Spectral efficient network and resource selection model in 5G networks
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Cloud computing and distributed systems.
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
20250228 LYD VKU AI Blended-Learning.pptx
Empathic Computing: Creating Shared Understanding
Chapter 3 Spatial Domain Image Processing.pdf
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Encapsulation theory and applications.pdf
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Diabetes mellitus diagnosis method based random forest with bat algorithm
Building Integrated photovoltaic BIPV_UPV.pdf
Review of recent advances in non-invasive hemoglobin estimation
A Presentation on Artificial Intelligence
Dropbox Q2 2025 Financial Results & Investor Presentation

Introduction To Ruby On Rails

  • 1. Introduction to Ruby on Rails Welcome to the puzzle….it’s a fun ride! By Steve Keener
  • 2. Terms you will hear Full stack Active Record Object Relational Model (ORM) MVC Gems RHTML Migration SVN
  • 3. What is RoR? It’s the next best thing to sliced bread? It’s the silver bullet to fix our project? It’s magic? None of these things. It’s a tool. But it was conceived as a highly productive tool where DRY is paramount. Don’t Repeat Yourself.
  • 4. Things you will need Ruby (Language) Rails (Framework in Ruby) Database Start here: www.rubyonrails.org/down You can download Instant Rails (Windows only). It contains Ruby, Rails, and MySQL for trying out the RoR world. You would use the command line and text editors to create applications.
  • 5. Available Development IDEs RadRails – Eclipse-based, integrated generators & servers. http://www.radrails.org/ TextMate – Mac oriented http://www.macromates.com/ I use RadRails. Downside is that code generators are still command line. But that’s a minor drawback.
  • 6. Source Code Repositories CVS – Doesn’t seem to be the preferred repository. Haven’t found an integrated delivery system. I used simple Ant scripts to build my delivery processes. SVN – Preferred repository and is integrated with Capistrano. (Rails version of application delivery systems.)
  • 7. After that… The first place to start the journey is by reading the article “Rolling with Ruby on Rails” by Curt Hibbs. http://www.onlamp.com/pub/a/onlamp/2005/01/20/rails.html
  • 8. Then what? You should pick up two books: Agile Web Development with Rails (Excellent) Rails Recipes (Great for finding specific functional modules you might need and having them running in an hour.)
  • 9. Other resources Rails online API http://api.rubyonrails.org/ Ruby Forums http://www.ruby-forum.com/user/login RubyForge http://rubyforge.org/
  • 10. On to Rails… Object Relational Mapping: ActiveRecord Like Java’s Hibernate (but simpler) Takes away a lot of the drudgery associated with web applications. (Create, Retrieve, Update, and Delete functions.)
  • 11. Full Stack J2EE Rails Webrick or Mongrel DispatchServlet RHTML ActionController ActiveRecord Database Layer Database Layer Hibernate Action Action Form JSP ActionServlet Tomcat Servlet Container Yes…they are fairly comparable…. Note: Found diagram on web
  • 12. Or another way to put it
  • 13. Or maybe this way…
  • 14. Rails vs J2EE Both have a learning curve RAILS has the edge in productivity by a significant margin. J2EE currently has an edge in scalability. If it’s a client facing system for millions of concurrent users – use J2EE. If it’s an internal web application, definitely take a look at this technology as a possible way of shortcutting the long development time for a J2EE web app.
  • 15. Can’t afford the time to learn a new framework!!! I needed a few screens to manage some dev data. Was investigating several different technologies to see what would best serve the need and timeframe. (J2EE, Hibernate, JSF, Rails, etc) Day 1 - Picked up a Ruby On Rails book, read a few articles, started experimenting. Day 2 - Stated building a few screens, relying on dynamic scaffolding for basic CRUD functionality Day 3 - Began replacing scaffold screens with better looking ones by hand. Day 4 – Started adding layouts, CCS, and some AJAX functionality to make application a bit nicer. Day 5 – Began investigating Models, Migrations, and RJS templates to enhance productivity. 5 days from start, over 50 screens produced, far more functionality than I had been planning, demos to multiple managers, and more than a few headaches. It’s not perfect, but is certainly a useful tool. (NOT A SILVER BULLET!!!!!!)
  • 16. Database New term – Migration: A powerful and flexible tool for managing database changes Allows table, index, and data creation scripts to be run in multiple environments with a very simple syntax. Need to revert back to a previous DB version to work on a bug? 1 command. Then refresh it back to the current dev version? 1 command.
  • 17. Example Migration class CreateMenuitems < ActiveRecord::Migration def self.up # Create the Menuitems table. The ID field does not need to be specified – automagically created. create_table :menuitems do |t| t.column :href , :string , :limit => 75 t.column :title , :string , :limit => 75 t.column :desc , :string , :limit => 75 t.column :leadtag , :string , :limit => 25 t.column :endtag , :string , :limit => 25 end item = Menuitem.create( :href => &quot;/menu/zero_dollars.html&quot;, :title => &quot;Zero dollar page1&quot;, :desc => &quot;Zero dollar ads1&quot;, :leadtag => &quot;<li>&quot;, :endtag => &quot;</li>&quot;) item.save end def self.down drop_table :menuitems end end
  • 18. MVC Model / View / Controller Model – Used for persistence and relationships View – Used for displaying the data Controller – The logic of the application
  • 19. Example Model class Node < ActiveRecord::Base end Yes….that’s it. Rails queries the database and determines the datatypes and fields for you. You can add data relationships, data validations to the model later. This is enough to get the scaffold screens up and running.
  • 20. Example View (With AJAX functionality thrown in) <h1>Listing nodes</h1> <table> <tr> <th>Desc</th> <th>Create date</th> <th>Status</th> </tr> <% @nodes . each do |n| %> <tr> <td> <%= @node = n; in_place_editor_field :node , :desc , {}, { :url => '/node/node_update_desc/' << @node .id.to_s, :rows => 1 , :cancelLink => 'false'} %> </td> <td width=&quot;50%&quot; align=&quot;center&quot;><%= n.created_at %></td> <td width=&quot;50%&quot; align=&quot;center&quot;><%= n.status %></td> </tr> <% end %> </table>
  • 21. Example Controller def list @nodes = Node.find( :all ) end - Uses the ActiveRecord Object Relational Mapping capabilities to pull all of the nodes in the Nodes table. No SQL written here to cause problems.
  • 22. Rails/Ruby conventions Ruby Gems – Like Java Jar files. Packages that can be installed. Taken one step further – simple installation methodologies. Convention over configuration. Use the “Rails Way”. The framework is designed to make development fast and easy. RHTML - HTML files with embedded Ruby/Rails code. Preprocessed into HTML
  • 23. Resources Rails API http://api.rubyonrails.org/ CSS Menus http://www.cssplay.co.uk/menus/index.html Live DataGrid http://unspace.ca/discover/datagrid/
  • 24. More… Subversion http://subversion.tigris.org/ Data Relationships diagram http://mboffin.com/stuff/ruby-on-rails-data-relationships.png Cheatsheets http://www.rubyonrailsblog.com/files/RoRblog-CheatSheet.pdf
  • 25. Cheatsheets Migration http://garrettsnider.backpackit.com/pub/367902 Rails http://www.rubyonrailsblog.com/files/RoRblog-CheatSheet.pdf Webservices on Rails http://manuals.rubyonrails.com/read/book/10 WebCast How-To site http://peepcode.com/
  • 26. Summary It’s an evolving toolset. DRY leads to fewer lines of code. Less code should mean less chances for bugs. Still requires normal analysis to be done on a project. But you can react far quicker to changes in requirements. A great tool for your toolbox.