windows下的rails2.02環境搭建指南

本文引用了諸多ror先輩們的經驗文章,在此希望大大們不要見怪。我發這篇文章的目的也是爲了後人少一些摸索,同時此文還發在railschina和railscn。
一、安裝Ruby
1、下載Ruby(http://www.ruby-lang.org)安裝包
雙擊安裝,安裝過程中注意選中"Enable RubyGems"
2、打開"命令提示符cmd",輸入"ruby -v"查看版本號,則表示ruby安裝成功

二、安裝Rails
1、下載JDK(http://java.sun.com/),安裝,否則下面的"gem install"會提示錯誤
2、下載Rails(http://www.rubyonrails.org) 這裏的版本爲:rails-2.0.2.gem
3、下載Rails安裝需要的庫(http://rubyforge.org/),注意有版本依賴問題。
這裏的版本爲:
activesupport-2.0.2.gem
activerecord-2.0.2.gem
actionpack-2.0.2.gem
actionmailer-2.0.2.gem
activeresource-2.0.2.gem

打開"命令提示符cmd"執行以下命令:
gem install activesupport-2.0.2.gem
gem install activerecord-2.0.2.gem
gem install actionpack-2.0.2.gem
gem install actionmailer-2.0.2.gem
gem install activeresource-2.0.2.gem
gem install rails-2.0.2.gem
安裝成功即可

或者將上面所有的.gem放在一個目錄中,然後直接在cmd中輸入下面的任何一個命令即可。
gem install rails -l
gem install rails -l --include-dependencies
gem install -l rails-2.0.2.gem

4、在cmd中運行"rails -v",顯示版本號,表示安裝成功
在cmd中運行"rails /new application"創建一個新項目
如"rails d:/new application"則可在D:\下看到新建的項目new
以上沒有出錯則rails安裝成功

5、使用:
運行 rails path/to/your/new/application 創建一個新的項目。
運行 ruby path/to/your/new/application/script/server 啓動服務。


=================================================================


瞭解RubyGems

1、什麼是Gem?
gem是Ruby程序或庫的打包方式,比如gem install rails就是安裝rails程序的gem
我們可以拿gem和war、jar類比
但是gem還擔當了Java裏maven的角色,就是一個庫管理工具,可以遠程下載和安裝Ruby庫

2、常用gem命令:

gem build -- Build a gem file from a specification
gem cert -- Support signing and managing signed gems
gem check -- Check installed gems for problems
gem cleanup -- Cleanup old versions in the repository
gem contents -- Display the files contained in an installed gem
gem dependency -- List the dependencies of a gem
gem environment -- Display information about the gem environment
gem help -- Provide help about gem commands
gem install -- Installing a gem
gem list -- List gems starting with a string
gem query -- Query for a list of gems
gem rdoc -- Generate the RDoc files for an installed gem
gem search -- List gems containing a string
gem specification -- Extract the Gem::Specification from a gem file
gem uninstall -- Uninstalling a gem
gem unpack -- Unpack an installed gem to the current directory
gem update -- Update your installed gems

3、升級已經安裝的gem:

因爲ruby1.86默認安裝的gem是0.94版的,現在最新的1.01已經出來了,將rubygems-update*.gem下載在某個目錄,在cmd下到此目錄,按如下指令即可升級:

gem install rubygems-update -l
update_rubygems


本文轉自
http://www.iteye.com/topic/151705?page=1

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章