views:

70

answers:

3

So in my local app, everything is fine.

Both are running Ruby 1.8.7, and Rails 2.3.5, however my deployed app gets the following error.

ActionView::TemplateError (undefined method `reduce' for #<Class:0x7fbbd034d760>)

The only difference that I can think of is the OS, I'm working on OS X and deploying to Linux.

That can't really be it though. Couldn't find anything online when it comes to reduce working any differently.

Any Ideas on how I can debug this?

Update

Out of curiosity I've updated ActiveSupport gem to 2.3.5 (activesupport-2.3.5) and that didn’t seem to work.

This is the line in the view that gets the error:

<%= quote.quote_line_items.reduce(0) {|sum, item| sum + item[:list_price].to_f } %>
+3  A: 

Check you deployment ruby version. reduce wasn't added to Enumerable until 1.8.7. You can also try using inject. It's the same as reduce, just with a less obvious name.

Dave Ray
You are both right... Why doesn't `reduce` work, I switched to inject, and that worked.
Joseph Silvashy
In 1.8.6, there was only inject. In 1.8.7 and 1.9, they added reduce as an alias, probably because that's what it's called in a lot of other languages.
Dave Ray
+1  A: 

reduce is a synonym for inject. So you should just change it to inject

newacct
+1  A: 

If you're looking to run multiple versions of Ruby or just want to try it out on different versions to see what breaks you can try rvm.

sudo gem install rvm
rvm install 1.8.7
rvm install 1.9.1
rvm use 1.9.1

This will set the default ruby to be 1.9.1 for ruby and all ruby associated programs like irb. Then you can easily deduce whether it's simply a 1.8.6 -> 1.8.7 thing or if it's something bigger.

Very handy when your server is locked into 1.8.6 but you want to see what's going to happen when you go to 1.8.7 or even 1.9.

Chuck Vose