俺也是 rails 小白,不是来显丑的, 看到http://ruby-china.org/topics/6011 提供给 mayday 做参考。
==========运行环境设置==========
I.安装相关软件 1.检查 heroku rails3 的准备 https://devcenter.heroku.com/articles/rails3#prerequisites #支持 rubyRuby 1.9.2, Rubygems, Bundler, and Rails 3. 2.下载并安装 ruby1.9.2 http://rubyforge.org/frs/download.php/75127/rubyinstaller-1.9.2-p290.exe #安装包,钩选所有选项 (安装 Tk 库/路径/??) 3.安 Gems Bundler cmd>gem update --system ##已经存在 gem,更新为 1.8.24 cmd>gem install bundler #安装 bundler,安装为 1.1.5 4.下载并安装 DevKit http://www.rubyinstaller.org/downloads https://github.com/downloads/oneclick/rubyinstaller/DevKit-tdm-32-4.5.2-20111229-1559-sfx.exe #Extract DevKit to path d:\Ruby192\DevKit cmd>cd d:\Ruby192\DevKit cmd>ruby dk.rb init cmd>ruby dk.rb review cmd>ruby dk.rb install 5.安装 rails3 cmd>gem install rails ..... unable to convert U+00A9 from UTF-8 to GBK for lib/rdoc/text.rb, skipping ..... 6.安装 Heroku toolbelt https://toolbelt.herokuapp.com/ #发现人家已经自带 ruby1.9.2 和 git 了,安装于 c:\program files\ruby-1.9.2\目录下 cmd>ren c:\program files\ruby-1.9.2\ruby-1.9.2_heroku\ cmd>mklink /d c:\program files\ruby-1.92. d:\ruby192 cmd>ruby -rubygems -e "require 'rdiscount'; puts RDiscount.new('Hello RubyInstaller').to_html" #运行正常 7.安装 sliqte3 命令行工具 sqlite-dll-win32-x86-3071401.zip 和 sqlite-shell-win32-x86-3071401.zip http://sqlite.org/download.html #copy sqlite3.def sqlite3.dll sqlite3.exe to d:\ruby192\bin\ 8.这时候桌面上应该有三个,git bash "git>", ruby "cmd>" , iruby "irb>", modify ruby working directory
II. 配置 GIT,生成 SSH Key,上传到 github 和 Heroku
III. Hello, Rails 1.验证本地 rails 安装 cmd>rails new hello cmd>cd hello cmd>rails generate controller say hello bye cmd>rails generate scaffold post title:string body:text created:datetime cmd>rake db:migrate #creating table posts cmd>rails server -p 1008 cmd>start http://127.0.0.1:1008/ cmd>start http://127.0.0.1:1008/say/hello cmd>start http://127.0.0.1:1008/posts #保存初始版本 cmd>git init cmd>git add . cmd>git commit -m "init" cmd>git tag v1.0
3.Hello, Heroku, Modified from sqlite3 to posgresql cmd>gvim Gemfile #'sqlite'->'pg' #参考https://devcenter.heroku.com/articles/rails3 cmd>gvim config/database.yml #'sqlite3'->'postgresql' 'test.sqlite3'->'hello_test' cmd>bundle install cmd>git add . cmd>git commit -m "heroku" cmd>git tag v1.2 #cmd>heroku login #用 dongxfatgmaildotcom 登陆 Heroku cmd>heroku create cmd>git push heroku master #pushing branch 'master' to heroku repository cmd>heroku run rake db:migrate #初始化远端数据库 cmd>start http://pacific-journey-1108.herokuapp.com/ cmd>start http://pacific-journey-1108.herokuapp.com/say/hello cmd>start http://pacific-journey-1108.herokuapp.com/say/bye cmd>start http://pacific-journey-1108.herokuapp.com/posts