Ruby on rails Rails 2.3.4和Ruby 1.9.1出现问题:未定义的方法“^';
我正在尝试测试一个带有数据库的rail应用程序的简单运行是否有效,我遇到了一个问题 以下是我正在采取的步骤:Ruby on rails Rails 2.3.4和Ruby 1.9.1出现问题:未定义的方法“^';,ruby-on-rails,Ruby On Rails,我正在尝试测试一个带有数据库的rail应用程序的简单运行是否有效,我遇到了一个问题 以下是我正在采取的步骤: > mkdir MyApp > cd MyApp > rails myapp ... > rake db:create ... > ruby script/generate scaffold user first_name:string last_name:string active:boolean ... > rake db:migrat
> 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
...
从这里开始,我第一次打开页面时会打开,然后单击“新建用户”。然后我得到这个错误:
用户中的命名错误#索引显示app/views/layouts/users.html.erb,其中第12行出现:
undefined method `^' for "7":String
RAILS\u ROOT:/Users/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是兼容的
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)
所以,从我在网上所能找到的,所有的事情都告诉我,这应该运行。我遗漏了什么?不久前我自己就必须解决这个问题。开始时的补丁(Jakub的不是hukl的)将解决问题。讨论还解释了为什么问题首先存在,Ruby 1.9处理字节的行为不同。不久前我自己就不得不解决这个问题。开始时的补丁(Jakub的不是hukl的)将解决问题。讨论还解释了为什么问题首先存在,Ruby 1.9处理字节的方式不同。感谢提供解决方案的for链接 此修补程序的链接是 从该文档中,我获取了代码并对文件进行了更改: lib/ruby/gems/1.9.1/gems/activesupport-2.3.4/lib/active\u support/message\u verifier.rb message\u verifier.rb旧版安全\u比较:
def secure_compare(a, b)
if a.length == b.length
result = 0
for i in 0..(a.length - 1)
result |= a[i] ^ b[i]
end
result == 0
else
false
end
end
def secure_compare(a, b)
if a.respond_to?(:bytesize)
# > 1.8.6 friendly version
if a.bytesize == b.bytesize
result = 0
j = b.each_byte
a.each_byte { |i| result |= i ^ j.next }
result == 0
else
false
end
else
# <= 1.8.6 friendly version
if a.size == b.size
result = 0
for i in 0..(a.length - 1)
result |= a[i] ^ b[i]
end
result == 0
else
false
end
end
end
message\u verifier.rb新建安全\u比较:
def secure_compare(a, b)
if a.length == b.length
result = 0
for i in 0..(a.length - 1)
result |= a[i] ^ b[i]
end
result == 0
else
false
end
end
def secure_compare(a, b)
if a.respond_to?(:bytesize)
# > 1.8.6 friendly version
if a.bytesize == b.bytesize
result = 0
j = b.each_byte
a.each_byte { |i| result |= i ^ j.next }
result == 0
else
false
end
else
# <= 1.8.6 friendly version
if a.size == b.size
result = 0
for i in 0..(a.length - 1)
result |= a[i] ^ b[i]
end
result == 0
else
false
end
end
end
def secure_比较(a、b)
如果a.回应?(:bytesize)
#>1.8.6友好版
如果a.bytesize==b.bytesize
结果=0
j=b.每个_字节
a、 每个_字节{| i | result |=i^j.next}
结果==0
其他的
错误的
终止
其他的
#感谢提供解决方案的for链接
此修补程序的链接是
从该文档中,我获取了代码并对文件进行了更改:
lib/ruby/gems/1.9.1/gems/activesupport-2.3.4/lib/active\u support/message\u verifier.rb
message\u verifier.rb旧版安全\u比较:
def secure_compare(a, b)
if a.length == b.length
result = 0
for i in 0..(a.length - 1)
result |= a[i] ^ b[i]
end
result == 0
else
false
end
end
def secure_compare(a, b)
if a.respond_to?(:bytesize)
# > 1.8.6 friendly version
if a.bytesize == b.bytesize
result = 0
j = b.each_byte
a.each_byte { |i| result |= i ^ j.next }
result == 0
else
false
end
else
# <= 1.8.6 friendly version
if a.size == b.size
result = 0
for i in 0..(a.length - 1)
result |= a[i] ^ b[i]
end
result == 0
else
false
end
end
end
message\u verifier.rb新建安全\u比较:
def secure_compare(a, b)
if a.length == b.length
result = 0
for i in 0..(a.length - 1)
result |= a[i] ^ b[i]
end
result == 0
else
false
end
end
def secure_compare(a, b)
if a.respond_to?(:bytesize)
# > 1.8.6 friendly version
if a.bytesize == b.bytesize
result = 0
j = b.each_byte
a.each_byte { |i| result |= i ^ j.next }
result == 0
else
false
end
else
# <= 1.8.6 friendly version
if a.size == b.size
result = 0
for i in 0..(a.length - 1)
result |= a[i] ^ b[i]
end
result == 0
else
false
end
end
end
def secure_比较(a、b)
如果a.回应?(:bytesize)
#>1.8.6友好版
如果a.bytesize==b.bytesize
结果=0
j=b.每个_字节
a、 每个_字节{| i | result |=i^j.next}
结果==0
其他的
错误的
终止
其他的
#我相信这与2.3.4版本是分不开的。对于测试,可以运行2.3.3。这个问题现在已经在edge中修复,所以下一个Rails版本应该会再次修复它!我相信这与2.3.4版本是分不开的。对于测试,可以运行2.3.3。这个问题现在已经在edge中修复,所以下一个Rails版本应该会再次修复它!