note for rails guide
来源:互联网 发布:玉米 番薯 知乎 编辑:程序博客网 时间:2024/06/11 09:21
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.drawdo
# 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
- note for rails guide
- Rails学习 note and
- Ruby on Rails guide
- Rails学习 note and mark.
- [Read note] Android Dev Guide -> Application Fundamentals
- Read note of HDFS User Guide
- First note for testing
- note for tty
- note for pci spec
- Note for Oracle
- Note for Shell
- Note for Linux
- Note for Sybase
- Note for iSON
- Note for Eclipse
- Note for Dos
- Note for AIX
- Note for Hadoop
- NoSQL数据库探讨 -- 非关系型数据库
- 动态ip怎样实现远程连接计算机?
- 000
- 系统性能调优
- 3D玫瑰JS
- note for rails guide
- python 取得 linux 主目录 “~/”
- 自学篇-&于&&不同之处(六)
- android文件操作
- java 之 断点续传和高速缓存
- Google某些网址访问不了的解决方法
- 魔方
- J2EE系统异常的处理准则
- 分页实现(jsp版)