• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Ruby on Rails Pei-Ying Wang
 

Ruby on Rails Pei-Ying Wang

on

  • 971 views

 

Statistics

Views

Total Views
971
Views on SlideShare
971
Embed Views
0

Actions

Likes
0
Downloads
9
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Ruby on Rails Pei-Ying Wang Ruby on Rails Pei-Ying Wang Presentation Transcript

    • Ruby on Rails Pei-Ying Wang peiatw@sfsu.edu
      • Overview
        • What is Ruby on Rails?
        • Rails frameworks (components)
        • Example: simple web application
        • Pros and Cons
    • What is Ruby on Rails?
      • Ruby  Ruby on Rails
        • An open source, interpreted scripting language
        • Created by Yukihiro Matsumoto in the mid-1990s
      • Ruby on Rails, ROR or Rails
        • An full-stack, open source web application framework written in Ruby
        • Designed for writing database-oriented real-world Web application quickly and easily
        • Created by David Heinemeier Hansson
    • What is Ruby on Rails?(2)
      • Very short history
        • Extracted from Basecamp(a project-management tool by 37Signals)
        • First released : July 2004
        • Latest release: April 2006(Version 1.1.2)
      • Principles(DRY- D on’t R epeat Y ourself)
        • Less software
        • Convention over Configuration
    • Rails Frameworks(components)
    • Example: a simple web application After starting MySQL and Web server, Create a new web application called cookbook2: > Rails cookbook2
    • Example: a simple web application(2) class MyTestController < ApplicationController end > ruby scriptgenerate controller MyTest To make a simple Hello World application:
    • Example: a simple web application(3) To make a simple Hello World application(2): class MyTestController < ApplicationController def index render_text &quot;Hello World&quot; end end http:// localhost :3000/My_Test/index http://localhost:3000//My_Test http://localhost:3000/MyTest
    • Example: a simple web application(4)
      • Online Recipe
        • First, create an database called cookbook2 and a table called recipes
    • Example: a simple web application(5) > ruby scriptgenerate model Recipe
    • Example: a simple web application(6) > ruby scriptgenerate controller Recipe Magic happens by simply adding this line to recipe_controller.rb !  Open browser and go to http:// localhost :3000/recipe/new
    • Example: a simple web application(7) Now, you can start to populate the database http://localhost:3000/recipe/new http://localhost:3000/recipe/new Click on the “create” button to add data
    • Example: a simple web application(8) http://localhost:3000/recipe/list http://localhost:3000/recipe/show/1
    • Example: a simple web application(9)
      • Add a list method in the file “recipe_controller.rb”
      • Take over the handling of the list action from the scaffolding
      Step1:
    • Example: a simple web application(10)
      • Add a new file called “ list.rhtml ” under app/views/receipe
      • .rhtml : an html file with Ruby code embedded within
      • <% %> and
      • <%= %> tags
      Step2: <html> <head> <title>All Recipes</title> </head> <body> <h1>Online Cookbook - All Recipes</h1> <table border=&quot;1&quot;> <tr> <td width=&quot;80%&quot;><p align=&quot;center&quot;><i><b>Recipe</b></i></td> <td width=&quot;20%&quot;><p align=&quot;center&quot;><i><b>Date</b></i></td> </tr> <% @recipes.each do |recipe| %> <tr> <td> <%= link_to recipe.title, :action => &quot;show&quot;, :id => recipe.id %> </td> <td> <%= recipe.date %> </td> </tr> <% end %> </table> <p> <%= link_to &quot;Create new recipe&quot;, :action => &quot;new&quot; %> </p> </body> </html>
    • Example: a simple web application(11)
      • Ask the recipe class for a collection of all recipes from the DB and assign the collection to the instance variable @recipes
      Step3:
    • Example: a simple web application(12) http://localhost:3000/recipe/list Done!
    • Pros and Cons
      • pros
        • Less code
        • High productivity & reduced development time
      • cons
        • too young
        • Upgrades in foundational code may result in instability in Rails
          • Relies on a foundation of numerous other applications
    • Reference
      • Russel Kay: QUICK STUDY: Ruby on Rails. Computerworld, 11/28/2005, Vol. 39 Issue 48, pg26-26
      • David Geer: Will Software Developers Rid Ruby on Rails to Success? Computer, Feb2006, Vol. 39 Issue 2, pg18-20
      • Stacy Cowley : Riding the ruby rails in a new direction  CRN. Jericho: Mar 13, 2006., Issue 1187;  pg. 43
      • Grant Buckler : Application developers climb aboard Ruby on Rails  Computing Canada. Willowdale: Aug 19, 2005.Vol.31, Issue 11;  pg. 6
      • Daniel Bogan: Get on track with ruby on rails http://www.sitepoint.com/article/ruby-on-rails
      • Curt Hibbs:What Is Ruby on Rails? http://www.onlamp.com/lpt/a/6251
      •   Bill Walton :Rolling with Ruby on [Instant]Rails http:// instantrails . rubyforge .org/tutorial/index.html
      • Curt Hibbs: Rolling with Ruby on Rails, Part 2 http://www.onlamp.com/lpt/a/5641
      • Curt Hibbs: Ajax on Rails http://www.onlamp.com/lpt/a/5944
      • http://en.wikipedia.org/wiki/Ruby_On_Rails
      • http://www.rubyonrails.com/