裝好Ruby On Rails後,可參考Rails指南的操作 http://guides.ruby.tw/rails3/getting_started.html
從第3點 建立新的 Rails 專案依序操作
先啟動rvm
source ~/.rvm/scripts/rvm
到目錄下
cd myblog
建資料庫
rake db:create
啟動web伺服器
rails server
///////////////////////////////////////////
準備好了就先作最簡單的練習 hallo rails
建立Controller與View
rails generate controller home index
編輯app/views/home/index.html.erb
加入<h1>Hello, Rails!</h1>
打開config/routes.rb,修改Rails首頁位置
找到 # root 'welcome#index' 這一行
改成 root 'home#index' 存檔
瀏覽器打開 http://localhost:3000 ,就會看到 Hello, Rails! 。
沒有留言:
張貼留言