在Windows下安裝rails

去以下網站下載、安裝rubyinstaller+DevKit

http://rubyinstaller.org/downloads/


輸入以下命令更換下載源:

C:\Ruby21-x64\bin>gem sources   --remove   https://rubygems.org/
https://rubygems.org/ removed from sources

C:\Ruby21-x64\bin>gem sources   -a   https://ruby.taobao.org/
https://ruby.taobao.org/ added to sources

C:\Ruby21-x64\bin>gem   sources   -l
*** CURRENT SOURCES ***


https://ruby.taobao.org/

因爲rails 4.2裏的activerecord-sqlserver-adapter 4.2不支持sqlserver 2005、2008、2008R2,所以安裝rails 4.1.9

C:\Ruby21-x64\bin>gem install rails -v 4.1.9


安裝DevKit,解壓t到一個固定目錄,例如:C:\Ruby21-x64\DevKit,然後執行以下命令

C:

CD C:\Ruby21-x64\DevKit

ruby   dk.rb   init

ruby   dk.rb   install


創建第一個WEB程序

cd  projects_dir

rails _4.1.9_ new test_app  -B -d sqlserver

cd test_app


修改Gemfile文件

將第1行的:source 'https://rubygems.org'  改爲: source 'https://ruby.taobao.org'

找到tzinfo-data這一行,平臺增加一個 改爲x64_mingw,即改爲: gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw]

加入一行:gem 'tiny_tds'

保存退出後,執行:

bundle update





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