我想测试一下,看看一个简单的带有数据库的铁路应用程序的运行是否可以正常工作,而且我正在运行问题。遇到Rails 2.3.4和Ruby 1.9.1的问题:未定义的方法`^'
这里是我采取的步骤:
> mkdir MyApp
> cd MyApp
> rails myapp
...
> rake db:create
...
> ruby script/generate scaffold user first_name:string last_name:string active:boolean
...
> rake db:migrate
...
> ruby script/server
...
从这里,我第一次打开http://localhost:3000/users页面将打开,然后我点击“新用户”。然后,我得到这个错误:
NoMethodError在用户#指数
显示应用程序/视图/布局/ users.html.erb其中第12行提出:
undefined method `^' for "7":String
RAILS_ROOT:/用户/ lillq/MyApp的
/usr/local/lib/ruby/gems/1.9.1/gems/activesupport-2.3.4/lib/active_support/message_verifier.rb:46:in `block in secure_compare'
/usr/local/lib/ruby/gems/1.9.1/gems/activesupport-2.3.4/lib/active_support/message_verifier.rb:45:in `each'
...
/usr/local/lib/ruby/gems/1.9.1/gems/actionpack-2.3.4/lib/action_view/base.rb:197:in `flash'
/Users/lillq/MyApp/app/views/layouts/users.html.erb:12:in `_run_erb_app47views47layouts47users46html46erb'
/Users/lillq/MyApp/app/controllers/users_controller.rb:7:in `index'
所以,首先我认为版本可能不兼容,但有几个问题说1.9.1和rails是兼容的。
两个说,铁路和Ruby 1.9应该工作。
因此,这里是我运行的版本:
lillq:~/MyApp > ruby --version
ruby 1.9.1p243 (2009-07-16 revision 24175) [i386-darwin10.0.0]
lillq:~/MyApp > gem --version
1.3.5
lillq:~/MyApp > gem list
*** LOCAL GEMS ***
actionmailer (2.3.4)
actionpack (2.3.4)
activerecord (2.3.4)
activeresource (2.3.4)
activesupport (2.3.4)
mysql (2.8.1)
rack (1.0.0)
rails (2.3.4)
rake (0.8.7)
sqlite3-ruby (1.2.5)
所以从我可以在网上找到,所有的事情都告诉我,这应该运行。我错过了什么?
我相信这与2.3.4版本打破了。为了测试,你可以运行2.3.3。现在这个问题已经得到解决,所以下一个Rails版本应该再次修复它! – NeilS 2009-10-01 06:43:03