Rails框架:如何演练Rails 2.1 RC1

Posted by cnruby Thu, 29 May 2008 09:01:00 GMT

Rails框架讲座:如何演练Rails 2.1 RC1

目录
 (一)系统环境:

  1. Ruby 语言 1.8.6版本, 点击这里Ruby1.8.4。要想安装多个Ruby语言运行环境请看这里
  2. Rails 框架 2.0.2版本,安装方法请看这里,最简单方法是第一种方法即可。
  3. Windows XP 或者 Windows 2000操作系统 或者 Linux Ubuntu操作系统
  4. 需要一个浏览器,如FireFox1.5.0.1以上版本。
  5. 开发编辑工具 Notepad2 ,安装方法请单击这里,复制一个notepad2.exe,并且更名为vi.exe。
  6. 在Windows XP上安装Linux核心命令,点击这里
  7. 如何在Windows Console下使用命令svn(下载软件),点击这里
  8. 在Windows上安装版本控制系统Git作为客户端使用,点击这里
  9. 安装数据库系统SQLite3,点击这里

 (二)前提条件:

  1. 在本机Winodw操作系统上,我们的工作目录为d:\works_rails2008。
  2. 你的电脑必须在线。
  3. 安装Rails框架插件thin:
    gem install thin --no-ri --no-rdoc

 (三)目的:

  1. 我们想要在一个已有Rails项目(版本为2.0.2)上安装和使用Rails框架最新版本2.1 RC1,注意不改变系统上的Rails框架版本。

 (四)解决方案:

  1. 创建一个Rails项目:
    rails test_project && cd test_project
  2. 查看系统Rails框架版本,应该还是版本2.0.2。
    rails -v
  3. 查看该Rails项目的版本信息
    ruby script/about
    输出结果:
    About your application's environment
    Ruby version              1.8.6 (i386-mswin32)
    RubyGems version          1.1.1
    Rails version             2.0.2
    Active Record version     2.0.2
    Action Pack version       2.0.2
    Active Resource version   2.0.2
    Action Mailer version     2.0.2
    Active Support version    2.0.2
    Application root          E:/coding/work_rails2008/test_project
    Environment               development
    Database adapter          sqlite3
  4. 安装Rails框架2.1 RC1到该Rails项目上
    git clone git://github.com/rails/rails.git vendor/rails
  5. 再一次查看该Rails项目的版本信息
    ruby script/about
    输出结果:
    About your application's environment
    Ruby version              1.8.6 (i386-mswin32)
    RubyGems version          1.1.1
    Rails version             2.0.991
    Active Record version     2.0.991
    Action Pack version       2.0.991
    Active Resource version   2.0.991
    Action Mailer version     2.0.991
    Active Support version    2.0.991
    Edge Rails revision       4d248543429918bc5a63e109e6f2327ffab9848b
    Application root          E:/coding/work_rails2008/test_project
    Environment               development
    Database adapter          sqlite3
    Database schema version   0
  6. 查看该Rails项目目录script文件
    ls script
    输出结果:
    about  console  destroy  generate  performance  plugin  process  runner  server
  7. 更新该Rails项目相关到Rails2.1 RC1内容
    rake rails:update
  8. 查看该Rails项目目录script文件,发现多了一个文件dbconsole
    ls script
    输出结果:
    about    dbconsole  generate     plugin   runner console  destroy    performance  process  server
  9. 为了使用上面这个新文件dbconsole,可以使用如下命令。该命令简化和统一了打开数据库方法。
    ruby script/dbconsole
    >>.exit
  10. 再次,查看系统Rails框架版本,应该还是版本2.0.2。
    rails -v
  11. 修改该Rails的相关配置文件environment.rb
    vi config/environment.rb
    【代码开始】
    。。。
    RAILS_GEM_VERSION = '2.0.991'
    。。。
    【代码结束】
  12. 创建该Rails的相关配置文件new_defaults.rb
    vi config/initializers/new_defaults.rb
    【代码开始】
    # These settins change the behavior of Rails 2 apps and will be defaults
    # for Rails 3. You can remove this initializer when Rails 3 is released.
    # Only save the attributes that have changed since the record was loaded.
    ActiveRecord::Base.partial_updates = true
    # Include ActiveRecord class name as root for JSON serialized output.
    ActiveRecord::Base.include_root_in_json = true
    # Use ISO 8601 format for JSON serialized times and dates
    ActiveSupport.use_standard_json_time_format = true
    # Don't escape HTML entities in JSON, leave that for the #json_escape helper
    # if you're including raw json in an HTML page.
    ActiveSupport.escape_html_entities_in_json = false
    【代码结束】
  13. 启动网络服务器thin,或者使用Mongrel。
    thin start

 (五)视听教学:



  (六)必须注意的问题:


 (七)参考资料:

  1. Rails 2.1将会有什么

 (八)命令清单:

rails test_project && cd test_project
rails -v
ruby script/about
git clone git://github.com/rails/rails.git vendor/rails
ruby script/about
ls script
rake rails:update
ls script
ruby script/dbconsole
 .exit
rails -v
vi config/environment.rb
【代码开始】
。。。
RAILS_GEM_VERSION = '2.0.991'
。。。
【代码结束】
vi config/initializers/new_defaults.rb
【代码开始】
# These settins change the behavior of Rails 2 apps and will be defaults
# for Rails 3. You can remove this initializer when Rails 3 is released.
# Only save the attributes that have changed since the record was loaded.
ActiveRecord::Base.partial_updates = true
# Include ActiveRecord class name as root for JSON serialized output.
ActiveRecord::Base.include_root_in_json = true
# Use ISO 8601 format for JSON serialized times and dates
ActiveSupport.use_standard_json_time_format = true
# Don't escape HTML entities in JSON, leave that for the #json_escape helper
# if you're including raw json in an HTML page.
ActiveSupport.escape_html_entities_in_json = false
【代码结束】
thin start



  (九)下载文件pdf:




________________________________________________________________ 您只要点击下面图标,就可以把本文加入到您喜欢的公共收藏库中去。
del.icio.us Digg | FURL | Yahoo! My Web 2.0 | Reddit | Blinklist | Fark

Posted in  | Tags , , ,

网络上品:Rails框架免费视频大全

Posted by cnruby Wed, 25 Jul 2007 18:49:00 GMT

网络上品:Rails框架免费视频大全


全面地学习Rails框架视频教材
完整的参考资料链接




________________________________________________________________ 您只要点击下面图标,就可以把本文加入到您喜欢的公共收藏库中去。
del.icio.us Digg | FURL | Yahoo! My Web 2.0 | Reddit | Blinklist | Fark

Posted in  | Tags , , , ,

Ruby语言:安装Windows XP的Ruby语言运行环境

Posted by cnruby Sat, 23 Jun 2007 04:37:00 GMT

Ruby语言:安装Windows XP的Ruby语言运行环境


  一般而言,在学习一门计算机语言或者用该语言开发和调试一个与之相关的软件项目时,我们至少需要该计算机语言的运行环境。由于计算机语言可以有不同的实现,也就是说利用不同技术和手段可以对同一个语言编写出不同的运行环境。即使是同一运行环境实现,针对不同的操作系统还可以有不同的版本。而且同一运行环境、同一版本和相同操作系统也会因为开发目标不同而有不同的软件打包和发布形式。这里所说的形式不仅仅指发布文件的打包形式,而是指包内的各组件不同。就是说:相同运行环境、相同版本、针对同一个操作系统,由于开发目标不同,该发行包可以再集成其它一些相关组件。某个具体的运行环境我们称为Ruby语言的具体实现(Implementation),或者称为一个Ruby语言运行环境的实例(Instance)。

  Ruby语言的官方网站实现既是运行环境也是开发环境。因为在本书中使用该实现,所以凡提到“运行环境”、“运行环境软件”、“运行系统”、或者“运行系统软件”都是一个意思,即一个可以运行和解释Ruby语言的程序及其相关软件包的整体。

  【注意】在Java语言环境下,既有运行环境也有开发环境。

  接下来,我们首先针对Windows XP操作系统环境说明官方Ruby语言运行环境软件的版本及其扩展软件。其次,推荐一个我们认为比较适合的的Ruby运行环境作为本书讲解Ruby语言的运行环境。最后,说明如何在同一个操作系统中安装多个Ruby语言运行环境的实例。

》》》》详细阅读,请点击这里


________________________________________________________________ 您只要点击下面图标,就可以把本文加入到您喜欢的公共收藏库中去。
del.icio.us Digg | FURL | Yahoo! My Web 2.0 | Reddit | Blinklist | Fark

Posted in  | Tags , , , , , , , ,