rails 学习
最近刚接触ruby和rails,留个笔记,记录碰到的问题(不定时更新)
资源 http://rubyforge.org/
问题使用rails2.3.4版本生成的工程,创建controller 无法被识别,于是升级rails为3.0试试,在升级中碰到问题,如下 环境ruby1.9.2p180. (on windows) gem1.7.1 1、 D:\mysql-5.0.18-win32\bin>gem install rails --version 3.0.0 Fetching: activesupport-3.0.0.gem (100%) ERROR: While executing gem ... (Gem::FormatException) builder-2.1.2 has an invalid value for @cert_chain
此问题是gem1.7.1的bug,网上建议使用1.6.2
gem update --system 1.6.2
再次安装 D:\mysql-5.0.18-win32\bin>gem install rails --version 3.0.0 Fetching: i18n-0.4.2.gem (100%) Fetching: activemodel-3.0.0.gem (100%) Fetching: rack-1.2.2.gem (100%) Fetching: rack-test-0.5.7.gem (100%) Fetching: rack-mount-0.6.14.gem (100%) Fetching: tzinfo-0.3.26.gem (100%) Fetching: abstract-1.0.0.gem (100%) Fetching: erubis-2.6.6.gem (100%) Fetching: actionpack-3.0.0.gem (100%) Fetching: arel-1.0.1.gem (100%) Fetching: activerecord-3.0.0.gem (100%) Fetching: activeresource-3.0.0.gem (100%) Fetching: mime-types-1.16.gem (100%) Fetching: polyglot-0.3.1.gem (100%) Fetching: treetop-1.4.9.gem (100%) Fetching: mail-2.2.15.gem (100%) Fetching: actionmailer-3.0.0.gem (100%) Fetching: thor-0.14.6.gem (100%) Fetching: railties-3.0.0.gem (100%) Fetching: bundler-1.0.11.gem (100%) Fetching: rails-3.0.0.gem (100%) Successfully installed builder-2.1.2 Successfully installed i18n-0.4.2 Successfully installed activemodel-3.0.0 Successfully installed rack-1.2.2 Successfully installed rack-test-0.5.7 Successfully installed rack-mount-0.6.14 Successfully installed tzinfo-0.3.26 Successfully installed abstract-1.0.0 Successfully installed erubis-2.6.6 Successfully installed actionpack-3.0.0 Successfully installed arel-1.0.1 Successfully installed activerecord-3.0.0 Successfully installed activeresource-3.0.0 Successfully installed mime-types-1.16 Successfully installed polyglot-0.3.1 Successfully installed treetop-1.4.9 Successfully installed mail-2.2.15 Successfully installed actionmailer-3.0.0 Successfully installed thor-0.14.6 Successfully installed railties-3.0.0 Successfully installed bundler-1.0.11 Successfully installed rails-3.0.0 22 gems installed Installing ri documentation for builder-2.1.2... Installing ri documentation for i18n-0.4.2... Installing ri documentation for activemodel-3.0.0... Installing ri documentation for rack-1.2.2... Installing ri documentation for rack-test-0.5.7... Installing ri documentation for rack-mount-0.6.14... Installing ri documentation for tzinfo-0.3.26... Installing ri documentation for abstract-1.0.0... Installing ri documentation for erubis-2.6.6... Installing ri documentation for actionpack-3.0.0... Installing ri documentation for arel-1.0.1... Installing ri documentation for activerecord-3.0.0... Installing ri documentation for activeresource-3.0.0... Installing ri documentation for mime-types-1.16... Installing ri documentation for polyglot-0.3.1... Installing ri documentation for treetop-1.4.9... Installing ri documentation for mail-2.2.15... Installing ri documentation for actionmailer-3.0.0... Installing ri documentation for thor-0.14.6... Installing ri documentation for railties-3.0.0... Installing ri documentation for bundler-1.0.11... Installing ri documentation for rails-3.0.0... Installing RDoc documentation for builder-2.1.2... Installing RDoc documentation for i18n-0.4.2... Installing RDoc documentation for activemodel-3.0.0... Installing RDoc documentation for rack-1.2.2... Installing RDoc documentation for rack-test-0.5.7... Installing RDoc documentation for rack-mount-0.6.14... Installing RDoc documentation for tzinfo-0.3.26... Installing RDoc documentation for abstract-1.0.0... Installing RDoc documentation for erubis-2.6.6... Installing RDoc documentation for actionpack-3.0.0... Installing RDoc documentation for arel-1.0.1... Installing RDoc documentation for activerecord-3.0.0... Installing RDoc documentation for activeresource-3.0.0... Installing RDoc documentation for mime-types-1.16... Installing RDoc documentation for polyglot-0.3.1... Installing RDoc documentation for treetop-1.4.9... Installing RDoc documentation for mail-2.2.15... Installing RDoc documentation for actionmailer-3.0.0... Installing RDoc documentation for thor-0.14.6... Installing RDoc documentation for railties-3.0.0... Installing RDoc documentation for bundler-1.0.11... Installing RDoc documentation for rails-3.0.0...
安装成功
2、卸载老版本模块的方法 D:\Ruby192\tmp\mybook>gem uninstall actionmailer -v 2.2.3 Successfully uninstalled actionmailer-2.2.3
3、创建工程后rails server启动web服务 提示 找不到sqllite.dll 或 无法定位程序输入点 sqlite3_backup_finish 于动态链接库 sqlite3.dll 需下载到http://www.sqlite.org/download.html下在 放到ruby安装目录bin下
4、生成工程后浏览 Routing Error
No route matches "/MyTest/hello" 修改工程config\routes.rb文件 match ':controller(/:action(/:id(.:format)))' 此行注释去掉,又出现下一个问题见5
5、编写例子,浏览时报 undefined method `render_text' 原因rails的新版本不用render_text了,改为render:text=>"hello world"就可以了(参考了http://qyongkang.iteye.com/blog/404604)