开发者

with_index in ruby 1.9.2

I upgraded to

ruby 1.9.2p290 (2011-07-09 revision 32开发者_如何学运维553)

Any idea why I get

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| %>

According to the doc: http://apidock.com/ruby/Enumerator/with_index if should work just fine. What am I missing?

Thanks Thomas


Are you sure you're using the version of Ruby you think you are? Might there be a .rvmrc in the directory you're doing this from? It works fine for me:

$ 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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜