note for rails guide

http://guides.ruby.tw/rails3/getting_started.html

$rails new blog #创建一个rails项目

$ cd blog #

$ bundle install  

#Rails 使用 Bundler gem 來管理所有你應用程式會依存的 gems 到 vendor 目錄。到目前為止,我們根據預設不需要特殊的 gem,我們只需要執行以下指令就可以準備好了


資料庫需要一個設定檔是 config/database.yml


$ rake db:create #讓 Rails 建立空的資料庫了


$ rails server #Ctrl C to exit


http://localhost:3000     #运行,看到public/index.html,静态页面。


$ rails generate controller home index #创建ctl,名字为home,并且有一个方法名为index #无modle


app/views/home/index.html.erb#修改其内容


$ cp public/index.htmlpublic/index.html.bak

$ rm public/index.html

$ vim config/routes.rb

mod like this ------

Blog::Application.routes.draw do

 # You can have the root of your site routed with "root"

# just remember to delete public/index.html.

root :to =>"home#index"


$ rails generate scaffold Post name:string title:string content:text


$ rake db:migrate


mod  app/view/home/index like this

<%= link_to "My Blog", posts_path %>

這個 link_to 函式是 Rails 內建的 view helpers (View 的輔助函式)。它會建立一個文字超連結,連到文章列表。







note for rails guide





aaaaaa





aaaa




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值