Getting Started with Rails 用Ruby on Rails純手工打造一個包含CRUD的RESTful應用程式 1. 建立一個專案 $rails new sample02 $cd sample02 2.建立一個名為board的model,其中包含title與content兩個欄位 $rails g model board title:string content:text $rake db:migrate 3.建立一個名為boards的controller $rails g controller boards 4.修改/config/routes.rb Sample02::Application.routes.draw do resources :boards 5.修改/config/routes.rb Sample02::Application.routes.draw do resources :boards 6./sample02/app/controllers/boards_controller.rb的基本結構有七組 class BoardsController < ApplicationController def index end def show end def new end def create end def edit end def update end def destroy end end 7.首先要先建立boards的index與show頁,修改/sample02/app/controllers/boards_controller.rb class BoardsController < ApplicationController def index @boards = Board.all end def show @board = Board.find(params[:id]) end end 8.建立views內index頁,/sample02/a