Ruby on Rails,环境安装和Gems(转载)

(这个ruby安装讲的还比较详细)

http://blog.csdn.net/abbuggy/article/details/7400848

如果你的电脑上没有安装Ruby,还等什么,我们去官方网站下载安装程序吧。对于运行Rails3.0,最低需要Ruby1.8.7,现在最新的稳定版应该是1.9.3。在Ruby的官方网站http://www.ruby-lang.org/有为不同操作系统安装Ruby使用的程序连接。如果使用的是windows,直接下载RubyInstaller并像安装普通软件一样安装就可以。我们安装Ruby是为了使用Rails,人家还给咱专门提供了同样基于RubyInstaller的RailsInstaller,能够将一些其他的开发工具一并安装,方便省力。最新版本的RailsInstaller是2.1.0,我们就用这个。这个版本附带有:    

  • Ruby 1.9.3-p125
  • Rails 3.2
  • Bundler 1.0.18
  • Git 1.7.6
  • Sqlite 3.7.3
  • TinyTDS 0.4.5
  • SQL Server support 3.3.3
  • DevKit


安装RailsInstaller时,最好选上“Add executables for Ruby,Git and DevKit to the PATH”,将Ruby,Git,DevKit的bin目录加入PATH环境变量中,方便直接在命令行中使用。当然你也可以不选则这个选项,改为每次执行命令时键入全路径。我没有测试过如果有中文或空格会不会出错,但为了避免不必要的麻烦还是谨慎为好。


如此一来安装工作完毕,测试一下是否工作正常。通过“开始-所有程序-RailsInstaller-Command Prompt with Ruby and Rails”启动命令行工作环境。

查看Ruby版本:

[plain]  view plain copy
  1. E:\greensoft\RailsInstaller>ruby -v  
  2. ruby 1.9.3p125 (2012-02-16) [i386-mingw32]  
查看Rails版本:

[plain]  view plain copy
  1. E:\greensoft\RailsInstaller>rails -v  
  2. Rails 3.2.1  
查看Gems版本:
[plain]  view plain copy
  1. E:\greensoft\RailsInstaller>gem -v  
  2. 1.8.19  

一切正常!

使用Rails的过程中你经常需要RubyGems(gem)工具来管理以及升级依赖的库(RubyGem)。RubyGem,就是一个个用Ruby语言编写的程序软件包,Rails就是一个最著名的RubyGemRubyGems是标准的Ruby包管理器,它的功能类似于Linux下的apt-get。

我们来使用gem查看一下RailsInstaller已经安装好的gem包:

[plain]  view plain copy
  1. E:\greensoft\RailsInstaller>gem list  
  2.   
  3. *** LOCAL GEMS ***  
  4.   
  5. actionmailer (3.2.1)  
  6. actionpack (3.2.1)  
  7. activemodel (3.2.1)  
  8. activerecord (3.2.1)  
  9. activerecord-sqlserver-adapter (3.2.1)  
  10. activeresource (3.2.1)  
  11. activesupport (3.2.1)  
  12. arel (3.0.2)  
  13. bigdecimal (1.1.0)  
  14. builder (3.0.0)  
  15. bundler (1.0.22)  
  16. coffee-rails (3.2.2)  
  17. coffee-script (2.2.0)  
  18. coffee-script-source (1.2.0)  
  19. erubis (2.7.0)  
  20. execjs (1.3.0)  
  21. hike (1.2.1)  
  22. i18n (0.6.0)  
  23. io-console (0.3)  
  24. journey (1.0.3, 1.0.2)  
  25. jquery-rails (2.0.1)  
  26. json (1.6.5, 1.5.4)  
  27. mail (2.4.4, 2.4.1)  
  28. mime-types (1.18, 1.17.2)  
  29. minitest (2.5.1)  
  30. multi_json (1.1.0)  
  31. mysql2 (0.3.11 x86-mingw32)  
  32. pg (0.13.1 x86-mingw32)  
  33. polyglot (0.3.3)  
  34. rack (1.4.1)  
  35. rack-cache (1.2, 1.1)  
  36. rack-ssl (1.3.2)  
  37. rack-test (0.6.1)  
  38. rails (3.2.1)  
  39. railties (3.2.1)  
  40. rake (0.9.2.2)  
  41. rb-readline (0.4.2)  
  42. rdoc (3.12, 3.9.4)  
  43. rubygems-update (1.8.19)  
  44. rubyzip (0.9.6.1)  
  45. sass (3.1.15)  
  46. sass-rails (3.2.5)  
  47. sprockets (2.1.2)  
  48. sqlite3 (1.3.5 x86-mingw32)  
  49. sqlite3-ruby (1.3.3)  
  50. thor (0.14.6)  
  51. tilt (1.3.3)  
  52. tiny_tds (0.5.1 x86-mingw32)  
  53. treetop (1.4.10)  
  54. tzinfo (0.3.32, 0.3.31)  
  55. uglifier (1.2.3)  

将gem工具升级到最新版本:

[plain]  view plain copy
  1. E:\greensoft\RailsInstaller>gem update --system  
  2. Updating rubygems-update  
  3. Fetching: rubygems-update-1.8.21.gem (100%)  
  4. Successfully installed rubygems-update-1.8.21  
  5. Installing RubyGems 1.8.21  
  6. RubyGems 1.8.21 installed  
  7.   
  8. == 1.8.21 / 2012-03-22  
  9.   
  10. * 2 bug fixes:  
  11.   
  12.   * Add workaround for buggy yaml output from 1.9.2  
  13.   * Force 1.9.1 to remove it's prelude code. Fixes #305  
  14.   
  15.   
  16. ------------------------------------------------------------------------------  
  17.   
  18. RubyGems installed the following executables:  
  19.     E:/greensoft/RailsInstaller/Ruby1.9.3/bin/gem  
  20.   
  21. RubyGems system software updated  

使用gem安装gem包:gem会访问internet,获取你希望安装的gem以及这个gem所依赖的其他gems。

[plain]  view plain copy
  1. E:\greensoft\RailsInstaller>gem install rake  
  2. Successfully installed rake-0.9.2.2  
  3. 1 gem installed  
  4. Installing ri documentation for rake-0.9.2.2...  
  5. 活动代码页: 936  
  6. Installing RDoc documentation for rake-0.9.2.2...  

有关查看gem工具使用的更多信息:

[plain]  view plain copy
  1. E:\greensoft\RailsInstaller>gem --help  
  2. RubyGems is a sophisticated package manager for Ruby.  This is a  
  3. basic help message containing pointers to more information.  
  4.   
  5.   Usage:  
  6.     gem -h/--help  
  7.     gem -v/--version  
  8.     gem command [arguments...] [options...]  
  9.   
  10.   Examples:  
  11.     gem install rake  
  12.     gem list --local  
  13.     gem build package.gemspec  
  14.     gem help install  
  15.   
  16.   Further help:  
  17.     gem help commands            list all 'gem' commands  
  18.     gem help examples            show some examples of usage  
  19.     gem help platforms           show information about platforms  
  20.     gem help <COMMAND>           show help on COMMAND  
  21.                                    (e.g. 'gem help install')  
  22.     gem server                   present a web page at  
  23.                                  http://localhost:8808/  
  24.                                  with info about installed gems  
  25.   Further information:  
  26.     http://rubygems.rubyforge.org  

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值