首先安装rails3, 目前版本是3.0.0.RC
gem install rails --pre
开始新建
首先看一下rails3 的新脚本
zool@zool-laptop:~/workspace$ rails Usage: rails new APP_PATH [options] Options: -b, [--builder=BUILDER] # Path to an application builder (can be a filesystem path or URL) [--dev] # Setup the application with Gemfile pointing to your Rails checkout [--edge] # Setup the application with Gemfile pointing to Rails repository [--skip-gemfile] # Don't create a Gemfile -m, [--template=TEMPLATE] # Path to an application template (can be a filesystem path or URL) -d, [--database=DATABASE] # Preconfigure for selected database (options: mysql/oracle/postgresql/sqlite3/frontbase/ibm_db) # Default: sqlite3 -O, [--skip-active-record] # Skip Active Record files -J, [--skip-prototype] # Skip Prototype files -T, [--skip-test-unit] # Skip Test::Unit files -r, [--ruby=PATH] # Path to the Ruby binary of your choice # Default: /home/zool/.rvm/rubies/ruby-1.8.7-p299/bin/ruby -G, [--skip-git] # Skip Git ignores and keeps Runtime options: -f, [--force] # Overwrite files that already exist -p, [--pretend] # Run but do not make any changes -s, [--skip] # Skip files that already exist -q, [--quiet] # Supress status output Rails options: -v, [--version] # Show Rails version number and quit -h, [--help] # Show this help message and quit Description: The 'rails new' command creates a new Rails application with a default directory structure and configuration at the path you specify. Example: rails new ~/Code/Ruby/weblog This generates a skeletal Rails installation in ~/Code/Ruby/weblog. See the README in the newly created application to get going.
开始新建项目
zool@zool-laptop:~/workspace$ rails new imatrix -d=mysql -J -T create create README create Rakefile create config.ru create .gitignore create Gemfile create app create app/helpers/application_helper.rb create app/views/layouts/application.html.erb create app/controllers/application_controller.rb create app/mailers create app/models create config create config/routes.rb create config/application.rb create config/environment.rb create config/environments create config/environments/test.rb create config/environments/development.rb create config/environments/production.rb create config/initializers create config/initializers/backtrace_silencers.rb create config/initializers/mime_types.rb create config/initializers/secret_token.rb create config/initializers/inflections.rb create config/initializers/session_store.rb create config/locales create config/locales/en.yml create config/boot.rb create config/database.yml create db create db/seeds.rb create doc create doc/README_FOR_APP create lib create lib/tasks create lib/tasks/.gitkeep create log create log/server.log create log/production.log create log/development.log create log/test.log create public create public/500.html create public/robots.txt create public/index.html create public/favicon.ico create public/422.html create public/404.html create public/images create public/images/rails.png create public/stylesheets create public/stylesheets/.gitkeep create public/javascripts create public/javascripts/.gitkeep create public/javascripts/application.js create script create script/rails create tmp create tmp/sessions create tmp/sockets create tmp/cache create tmp/pids create vendor/plugins create vendor/plugins/.gitkeep
备忘:
1. rails3 新建项目需要用rails new 来新建
2. -d=mysql 指定使用mysql数据, 默认为sqlite3
3. -J 跳过建立prototype文件, 现在用JQuery比较多, 之后项目准备用JQ
4.-T 跳过建立Test::Unit文件, 之后的测试准备用spec
5. rail3默认建立gitignore和gitkeep文件, 可以用 -G 参数跳过
然后编辑config/database.yml
rake db:create
rake db:migrate
启动服务
rails s
备忘:
rails3 中将原来的script/* 都合并为一个脚本 script/rails
因此rails2中的 script/server 就改为了 rails server ,并且由于提供了short-cut,直接用 rails s就可以启动
建立git
git init
git add .
git commit -m 'imatrix init'
git remote add origin [email protected]:zhooul/imatrix.git
git push origin master
备注:
github的ssh配置
http://help.github.com/linux-key-setup/