升级到
ruby 1.9.2p290 (2011-07-09 revision 32553)
知道为什么我得到
吗?ArgumentError in Territories#show
Showing /home/Thomas/territory_management/app/views/territories/show.html.erb where line #24 raised:
wrong number of arguments (1 for 0)
Extracted source (around line #24):
24: <% @addresses.to_enum.with_index(1).each do |address, index| %>
根据文档:http://apidock.com/ruby/Enumerator/with_index它应该工作得很好。我错过了什么?
谢谢托马斯。
你确定你使用的是你认为的Ruby版本吗?在您执行此操作的目录中是否存在.rvmrc
?
$ ruby --version
ruby 1.9.2p290 (2011-07-09 revision 32553) [i686-linux]
$ rails c
Loading development environment (Rails 3.0.9)
pry(main)> users = User.limit(5)
pry(main)> users.to_enum.with_index(5).each { |ex, i| puts "#{i}: #{ex.name}" }
5: Dave
6: Nick
7: Keenan
8: Hater
9: Greg