• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content

Loading…

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

Like this presentation? Why not share!

Ruby On Rails

on

  • 422 views

 

Statistics

Views

Total Views
422
Views on SlideShare
422
Embed Views
0

Actions

Likes
0
Downloads
0
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 Ruby On Rails Presentation Transcript

    • Ruby On Rails [email_address]
    • What is RoR?
      • Ruby (C#)
      • Rails (.Net Framework)
        • Open Source
        • Web Application Framework
        • Written in Ruby
        • Model-View-Controller (MVC) Architecture.
      http://en.wikipedia.org/wiki/Ruby_on_Rails
    • Softwares
      • InstantRails
        • 為一解壓縮後即可運行的軟體 ( 執行檔 : InstantRails.exe) ,免安裝。內含 Ruby 程式語言 , Rails 網頁應用程式框架 , Apache 網站伺服器 及 MySQL 資料庫,以及 phpMyAdmin 可透過瀏覽器管理 MySQL 資料庫。
      • sciTE
        • 編輯器
        • http://prdownloads.sourceforge.net/scintilla/Sc171.exe
    • 2006/11 2005/11 2006/11 http://www.tiobe.com/tpci.htm Ruby is rocketing skywards
    • http://lightyror.blogspot.com/2006/11/tiobe-11ruby.html
    • http://radar.oreilly.com/archives/2006/11/state_of_the_co_1.html
    •  
    • http://blog.thinkphp.de/archives/170-Keynote-of- Tim-Bray -some-interesting-comparison-between-PHP,-Rails-and-Java.html Who is Tim Bray? http://www.w3.org/TR/2006/REC-xml-20060816/
    • 大公司對於 Ruby and Ruby on Rails 的動作列表
      • SUN : Sun 僱用了 JRuby 核心開發者
      • Amazon : Amazon 疑似加碼 37 Signal ?
      • Yahoo : Yahoo Developer Network 也開始加入 Ruby 選項
      • Microsoft : MS 聘了 RubyCLR 創造者
      • Google : Google 買下用 Ruby on Rails 寫的 Measure Map 。這家公司也擁有 Rails Core Team 其中一員 Nicholas Seckar 。
      • IBM : IBM 採用 Ruby on Rails 來開發 Koala Project 。
      http://lightyror.blogspot.com/2006/11/ruby-and-ruby-on-rails.html
    • Model-View-Controller View Model Controller A B AB O 血型 function update{ } A 血型 姓名 曹操 O 孫權 list edit 姓名 : 曹操 血型 : (*)A ( )B ( )AB ( )O 姓名 血型 曹操 A 孫權 B 編輯 編輯 存檔
    • list recipe/list recipe/edit/2 cookbook2 http://localhost:3000/recipe
    • cookbook2 Application Cookbook2 rails cookbook2 cookbook2 app config database.yml models controllers recipe.rb recipe_controller.rb ruby script/generate model Recipe ruby script/generate controller Recipe 1 2 4 3 5 ruby script/server 6
    • recipe/list recipe/edit/2 cookbook2
    • Category
      • DB: create table categories (id, name)
      • generate model Category
      • Generate controller Category
        • scaffold :category
      • Add Data /category/list
        • New Category Snacks
        • New Category Beverages
    • Model recipe belong_to category
      • DB: recipes add field category_id
      • model/recipe.rb
        • belongs_to :category
      • model/category.rb
        • has_many :recipes
      • 我以為這樣就可以了
    • recipe_controller.rb
      • class RecipeController < ApplicationController scaffold :recipe
      • def edit
      • @recipe = Recipe.find(@params[&quot;id&quot;])
      • @categories = Category.find_all
      • end
      • end
      • <html>
      • <head>
      • <title>Edit Recipe</title>
      • </head>
      • <body>
      • <h1>
      • Edit Recipe</h1>
      • <form action=&quot;../update/ <%= @recipe.id %> &quot; method=&quot;POST&quot;&quot;>
      • <input id=&quot;recipe_id&quot; name=&quot;recipe[id]&quot; size=&quot;30&quot; type=&quot;hidden&quot; value=&quot; <%= @recipe.id %> &quot; />
      • <p>
      • <b>Title</b><br>
      • <input id=&quot;recipe_title&quot; name=&quot;recipe[title]&quot; size=&quot;30&quot; type=&quot;text&quot; value=&quot; <%= @recipe.title %> &quot; />
      • </p>
      views ecipeedit.rhtml 1/3
      • <p>
      • <b>Category:</b><br>
      • <select name=&quot;recipe[category_id]&quot;>
        • <% @categories.each do |category| %>
        • <option value =&quot;<%= category.id %> &quot;
        • <%= ' selected' if category.id == @recipe.category_id %> >
        • <%= category.name %>
        • </option>
        • <% end %>
      • </select>
      • </p>
      views ecipeedit.rhtml 2/3
      • <p>
      • <b>Instructions</b><br>
      • <textarea cols=&quot;40&quot; id=&quot;recipe_instructions&quot; name=&quot;recipe[instructions]&quot; rows=&quot;20&quot; wrap=&quot;virtual&quot;> <%= @recipe.instructions %>
      • </textarea>
      • </p>
      • <input type=&quot;submit&quot; value=&quot;Update&quot; />
      • </form>
      • <a href=&quot;/recipe/show /<%= @recipe.id %> &quot;>Show </a>
      • | <a href=&quot;/recipe/list&quot;>Back </a>
      • </body>
      • </html>
      views ecipeedit.rhtml 3/3
    • Generate scaffold
      • Ruby script/generate scaffold Category Admin
      • Ruby script/generate scaffold Recipe Use
    • Generate scaffold
      • <h1>Editing recipe</h1>
      • <%= start_form_tag :action => 'update', :id => @recipe %> <%= render :partial => 'form' %>
      • <%= submit_tag 'Edit' %>
      • <%= end_form_tag %>
      • <%= link_to 'Show', :action => 'show', :id => @recipe %>
      • |<%= link_to 'Back', :action => 'list' %>
      • http://www.rubyonrails.org.tw/