This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Ruby 1.8.7 and Rails 3.0pre | |
$ sudo gem install unicorn | |
$ rails blog -m http://www.lycom.de/files/rails-templates/rails187.txt && cd blog | |
$ unicorn # similar to the command "rails server" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ Rails demo && cd demo | |
$ bundle check | |
$ bundle show #不会看到RedCloth,即使你的Ruby环境安装了RedCloth。 | |
$ vim Gemfile | |
gem "RedCloth" #需要增加的代码 | |
$ bundle check #出现错误,如果Ruby环境没有安装RedCloth。 | |
$ sudo gem install RedCloth | |
$ bundle check #一切正常,如果你安装RedCloth没有错误的话。 | |
$ bundle show |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ Rails demo && cd demo | |
$ bundle check | |
$ bundle show #不会看到RedCloth,即使你的Ruby环境安装了RedCloth。 | |
$ vim Gemfile | |
gem "RedCloth" #需要增加的代码 | |
$ bundle check #出现错误,如果Ruby环境没有安装RedCloth。 | |
$ sudo bundle install RedCloth | |
$ bundle check #一切正常,如果你安装RedCloth没有错误的话。 | |
$ bundle show |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ # 安装Rails3.0pre版本 | |
$ sudo gem install tzinfo builder memcache-client rack rack-test rack-mount erubis mail text-format thor bundler i18n sqlite3-ruby | |
$ sudo gem install rails --pre | |
$ # 使用templates技术开发Rails程序 | |
$ sudo vim $HOME/.rvm/rubies/ruby-1.8.7-p249/lib/ruby/gems/1.8/gems/railties-3.0.0.beta/lib/rails/generators/actions.rb | |
# 参考 http://www.lycom.de/past/2010/2/8/2010-02-07-rails3-pre/ 上图。 | |
** rails blog -m http://www.lycom.de/files/rails-templates/rails187.txt && cd blog | |
$ # 使用Rails程序 | |
$ rails server | |
$ open http://localhost:3000/posts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ # 安装gem软件包rvm | |
$ sudo gem install rvm | |
$ rvm-install | |
$ vim ~/.profile #该文件名称不一定每个系统都相同。下面一行代码存放到该文件的最后一行,但是在其后不能够有空行!完成此操作以后,需要打开新的终端,看看是否出现错误。没有错误说明此操作正常。切记:下面的所有操作命令将在新终端窗口进行。 | |
if [[ -s ${HOME}/.rvm/scripts/rvm ]] ; then source ${HOME}/.rvm/scripts/rvm ; fi # 需要增加的代码 | |
$ # 安装Ruby1.9.1命令(第二行命令是因为第一行命令安装出现错误上进行的补救命令) | |
$ rvm install 1.9.1 | |
$ sudo $HOME/.rvm/rubies/ruby-1.9.1-p378/bin/gem install rake | |
$ # 使用Ruby1.9.1切换命令 | |
$ rvm 1.9.1 #打开新的终端还是Ruby 1.8.6 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ # 安装gem软件包rvm | |
$ sudo gem install rvm | |
$ rvm-install | |
$ vim ~/.profile #该文件名称不一定每个系统都相同。下面一行代码存放到该文件的最后一行,但是在其后不能够有空行!完成此操作以后,需要打开新的终端,看看是否出现错误。没有错误说明此操作正常。切记:下面的所有操作命令将在新终端窗口进行。 | |
if [[ -s ${HOME}/.rvm/scripts/rvm ]] ; then source ${HOME}/.rvm/scripts/rvm ; fi # 需要增加的代码 | |
$ # 安装Readline | |
$ rvm package install readline | |
$ # 安装Ruby 1.8.7 | |
$ rvm install 1.8.7 -C --enable-shared,--with-readline-dir=$HOME/.rvm/usr | |
$ # 使用Ruby1.8.7切换命令 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ # 本地创建Rails程序命令 | |
$ rails blog -m ./hirb.rb | |
$ # 远程创建Rails程序命令 | |
$ rails blog -m http://www.lycom.de/files/rails-templates/hirb.txt | |
$ cd blog |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ # Ruby 1.8.6 + Rails 2.3.5 | |
$ # http://www.lycom.de/past/2009/12/16/2009-12-18-hirb/ | |
$ | |
$ | |
$ ./script/console | |
>> post = Post.find :first | |
>> require 'hirb' | |
>> Hirb.enable | |
>> post | |
>> post_short = Post.find :first, :select=>'id, title' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# http://chinaonrails.com/topic/view/3730.html | |
class Dir | |
def xget # 传统编写代码方式,目的返回一个Array | |
n = [] | |
while name = self.read | |
n << name | |
end | |
n | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ rails plugin install # ./script/plugin install | |
$ rails generate # ./script/generate | |
$ rails g # ./script/generate | |
$ rails console # ./script/console | |
$ rails c # ./script/console |
OlderNewer