你的分享就是我们的动力 ---﹥

Installing Ruby on Rails

时间:2013-04-05 21:58来源:www.chengxuyuans.com 点击:

对于新手推荐使用Railsinstaller来安装Ruby on Rails,刚开始减少在安装阶段过多的纠缠,快速进入框架学习阶段。

1.下载Railsinstaller

site:http://railsinstaller.org/

对新手来说,Railsinstaller非常方便,里边包含了所有ROR需要的软件,可谓一站式安装。


2.安装Railsinstaller

唯一一点要注意的是,安装路径不要有空格


3.安装完之后,输入github的用户名和邮箱


4.重开一个命令行,查看各个组件是否安装成功

C:\Documents and Settings\XPMUser>ruby -v
ruby 1.9.3p392 (2013-02-22) [i386-mingw32]

C:\Documents and Settings\XPMUser>rails -v
Rails 3.2.13

C:\Documents and Settings\XPMUser>gem -v
1.8.24


5.(optional)更新rails

C:\Documents and Settings\XPMUser>gem update rails
Updating installed gems
Nothing to update

到这里安装基本就算完成了,接下来测试下安装成果,创建一个项目看看运行情况,创建一个最简单的待办事务

C:\Work>rails new todos
      create
      create  README.rdoc
      create  Rakefile
      create  config.ru
      create  .gitignore
      create  Gemfile
      create  app
      create  app/assets/images/rails.png
      create  app/assets/javascripts/application.js
      create  app/assets/stylesheets/application.css
      create  app/controllers/application_controller.rb
      create  app/helpers/application_helper.rb
      create  app/views/layouts/application.html.erb
      create  app/mailers/.gitkeep
      create  app/models/.gitkeep
      create  config
      create  config/routes.rb
      create  config/application.rb
      create  config/environment.rb
      create  config/environments
      create  config/environments/development.rb
      create  config/environments/production.rb
      create  config/environments/test.rb
      create  config/initializers
      create  config/initializers/backtrace_silencers.rb
      create  config/initializers/inflections.rb
      create  config/initializers/mime_types.rb
      create  config/initializers/secret_token.rb
      create  config/initializers/session_store.rb
      create  config/initializers/wrap_parameters.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  lib/assets
      create  lib/assets/.gitkeep
      create  log
      create  log/.gitkeep
      create  public
      create  public/404.html
      create  public/422.html
      create  public/500.html
      create  public/favicon.ico
      create  public/index.html
      create  public/robots.txt
      create  script
      create  script/rails
      create  test/fixtures
      create  test/fixtures/.gitkeep
      create  test/functional
      create  test/functional/.gitkeep
      create  test/integration
      create  test/integration/.gitkeep
      create  test/unit
      create  test/unit/.gitkeep
      create  test/performance/browsing_test.rb
      create  test/test_helper.rb
      create  tmp/cache
      create  tmp/cache/assets
      create  vendor/assets/javascripts
      create  vendor/assets/javascripts/.gitkeep
      create  vendor/assets/stylesheets
      create  vendor/assets/stylesheets/.gitkeep
      create  vendor/plugins
      create  vendor/plugins/.gitkeep
         run  bundle install
Fetching gem metadata from https://rubygems.org/...........
Fetching gem metadata from https://rubygems.org/..
Resolving dependencies...
Installing rake (10.0.4)
Using i18n (0.6.1)
Installing multi_json (1.7.2)
Using activesupport (3.2.13)
Using builder (3.0.4)
Using activemodel (3.2.13)
Using erubis (2.7.0)
Using journey (1.0.4)
Using rack (1.4.5)
Using rack-cache (1.2)
Using rack-test (0.6.2)
Using hike (1.2.1)
Using tilt (1.3.6)
Using sprockets (2.2.2)
Using actionpack (3.2.13)
Installing mime-types (1.22)
Using polyglot (0.3.3)
Using treetop (1.4.12)
Using mail (2.5.3)
Using actionmailer (3.2.13)
Using arel (3.0.2)
Using tzinfo (0.3.37)
Using activerecord (3.2.13)
Using activeresource (3.2.13)
Using bundler (1.3.4)
Installing coffee-script-source (1.6.2)
Using execjs (1.4.0)
Using coffee-script (2.2.0)
Using rack-ssl (1.3.3)
Installing json (1.7.7)
Installing rdoc (3.12.2)
Installing thor (0.18.1)
Using railties (3.2.13)
Using coffee-rails (3.2.2)
Using jquery-rails (2.2.1)
Using rails (3.2.13)
Using sass (3.2.7)
Using sass-rails (3.2.6)
Using sqlite3 (1.3.7)
Installing uglifier (1.3.0)
Your bundle is complete!
Use `bundle show [gemname]` to see where a bundled gem is installed.
Post-install message from rdoc:
Depending on your version of ruby, you may need to install ruby rdoc/ri data:

<= 1.8.6 : unsupported
= 1.8.7 : gem install rdoc-data; rdoc-data --install
= 1.9.1 : gem install rdoc-data; rdoc-data --install
>= 1.9.2 : nothing to do! Yay!


C:\Work> cd todos


创建代办事务

C:\Work\todos>rails g scaffold todo name:string due_on:date completed:boolean
      invoke  active_record
      create    db/migrate/20130405082541_create_todos.rb
      create    app/models/todo.rb
      invoke    test_unit
      create      test/unit/todo_test.rb
      create      test/fixtures/todos.yml
      invoke  resource_route
       route    resources :todos
      invoke  scaffold_controller
      create    app/controllers/todos_controller.rb
      invoke    erb
      create      app/views/todos
      create      app/views/todos/index.html.erb
      create      app/views/todos/edit.html.erb
      create      app/views/todos/show.html.erb
      create      app/views/todos/new.html.erb
      create      app/views/todos/_form.html.erb
      invoke    test_unit
      create      test/functional/todos_controller_test.rb
      invoke    helper
      create      app/helpers/todos_helper.rb
      invoke      test_unit
      create        test/unit/helpers/todos_helper_test.rb
      invoke  assets
      invoke    coffee
      create      app/assets/javascripts/todos.js.coffee
      invoke    scss
      create      app/assets/stylesheets/todos.css.scss
      invoke  scss
      create    app/assets/stylesheets/scaffolds.css.scss

database migration
C:\Work\todos>rake db:migrate
==  CreateTodos: migrating ====================================================
-- create_table(:todos)
   -> 0.0100s
==  CreateTodos: migrated (0.0100s) ===========================================


启动Rails应用
C:\Work\todos>rails s
=> Booting WEBrick
=> Rails 3.2.13 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
[2013-04-05 16:27:08] INFO  WEBrick 1.3.1
[2013-04-05 16:27:08] INFO  ruby 1.9.3 (2013-02-22) [i386-mingw32]
[2013-04-05 16:27:08] INFO  WEBrick::HTTPServer#start: pid=2396 port=3000

测试结果:
http://localhost:3000/todos









本文地址http://www.chengxuyuans.com/oracle/55604.html

其他频道: MySQL SQL Server oracle DB2 sybase