spree/spree — Issue #887: String can't be coerced into BigDecimal
Author: raskhadafi
Created: 2011-12-19 10:57:56+00:00
State: open

When I use ruby 1.8.7 I get this error with ruby 1.9.2 it works fine.

```
Showing vendor/bundle/bundler/gems/spree-81d257dcf847/core/app/views/spree/checkout/_delivery.html.erb where line #10 raised:

String can't be coerced into BigDecimal
Extracted source (around line #10):

7:
8: <%= radio_button(:order, :shipping_method_id, shipping_method[:id]) %>
9: <% if Spree::Config[:shipment_inc_vat] %>
10: <%= shipping_method[:name] %> <%= format_price (1 + Spree::TaxRate.default) * shipping_method[:cost] %>
11: <% else %>
12: <%= shipping_method[:name] %> <%= number_to_currency shipping_method[:cost] %>
13: <% end %>
```

And the full trace is:

```
vendor/bundle/bundler/gems/spree-81d257dcf847/core/app/views/spree/checkout/_delivery.html.erb:10:in `*'
vendor/bundle/bundler/gems/spree-81d257dcf847/core/app/views/spree/checkout/_delivery.html.erb:10:in `_vendor_bundle_bundler_gems_spree___d___dcf____core_app_views_spree_checkout__delivery_html_erb__45132820_2558521960'
vendor/bundle/bundler/gems/spree-81d257dcf847/core/app/views/spree/checkout/_delivery.html.erb:6:in `each'
vendor/bundle/bundler/gems/spree-81d257dcf847/core/app/views/spree/checkout/_delivery.html.erb:6:in `_vendor_bundle_bundler_gems_spree___d___dcf____core_app_views_spree_checkout__delivery_html_erb__45132820_2558521960'
vendor/bundle/gems/actionpack-3.1.1/lib/action_view/template.rb:144:in `send'
vendor/bundle/gems/actionpack-3.1.1/lib/action_view/template.rb:144:in `render'
vendor/bundle/gems/activesupport-3.1.1/lib/active_support/notifications.rb:55:in `instrument'
vendor/bundle/gems/actionpack-3.1.1/lib/action_view/template.rb:142:in `render'
vendor/bundle/gems/actionpack-3.1.1/lib/action_view/renderer/partial_renderer.rb:256:in `render_partial'
vendor/bundle/gems/actionpack-3.1.1/lib/action_view/renderer/partial_renderer.rb:228:in `render'
vendor/bundle/gems/actionpack-3.1.1/lib/action_view/renderer/abstract_renderer.rb:33:in `instrument'
vendor/bundle/gems/activesupport-3.1.1/lib/active_support/notifications.rb:53:in `instrument'
vendor/bundle/gems/activesupport-3.1.1/lib/active_support/notifications/instrumenter.rb:21:in `instrument'
vendor/bundle/gems/activesupport-3.1.1/lib/active_support/notifications.rb:53:in `instrument'
vendor/bundle/gems/actionpack-3.1.1/lib/action_view/renderer/abstract_renderer.rb:33:in `instrument'
vendor/bundle/gems/actionpack-3.1.1/lib/action_view/renderer/partial_renderer.rb:227:in `render'
vendor/bundle/gems/actionpack-3.1.1/lib/action_view/renderer/abstract_renderer.rb:22:in `wrap_formats'
vendor/bundle/gems/actionpack-3.1.1/lib/action_view/renderer/partial_renderer.rb:219:in `render'
vendor/bundle/gems/actionpack-3.1.1/lib/action_view/renderer/renderer.rb:41:in `render_partial'
vendor/bundle/gems/actionpack-3.1.1/lib/action_view/helpers/rendering_helper.rb:27:in `render'
vendor/bundle/bundler/gems/spree-81d257dcf847/core/app/views/spree/checkout/edit.html.erb:15:in `_vendor_bundle_bundler_gems_spree___d___dcf____core_app_views_spree_checkout_edit_html_erb__1201782643_2556494740'
vendor/bundle/gems/actionpack-3.1.1/lib/action_view/helpers/capture_helper.rb:40:in `capture'
vendor/bundle/gems/actionpack-3.1.1/lib/action_view/helpers/capture_helper.rb:187:in `with_output_buffer'
vendor/bundle/gems/actionpack-3.1.1/lib/action_view/helpers/capture_helper.rb:40:in `capture'
vendor/bundle/gems/actionpack-3.1.1/lib/action_view/helpers/form_helper.rb:590:in `fields_for'
vendor/bundle/gems/actionpack-3.1.1/lib/action_view/helpers/form_helper.rb:373:in `form_for'
vendor/bundle/bundler/gems/spree-81d257dcf847/core/app/views/spree/checkout/edit.html.erb:14:in `_vendor_bundle_bundler_gems_spree___d___dcf____core_app_views_spree_checkout_edit_html_erb__1201782643_2556494740'
vendor/bundle/gems/actionpack-3.1.1/lib/action_view/template.rb:144:in `send'
vendor/bundle/gems/actionpack-3.1.1/lib/action_view/template.rb:144:in `render'
vendor/bundle/gems/activesupport-3.1.1/lib/active_support/notifications.rb:55:in `instrument'
vendor/bundle/gems/actionpack-3.1.1/lib/action_view/template.rb:142:in `render'
vendor/bundle/gems/actionpack-3.1.1/lib/action_view/renderer/template_renderer.rb:40:in `render_template'
vendor/bundle/gems/actionpack-3.1.1/lib/action_view/renderer/abstract_renderer.rb:33:in `instrument'
vendor/bundle/gems/activesupport-3.1.1/lib/active_support/notifications.rb:53:in `instrument'
vendor/bundle/gems/activesupport-3.1.1/lib/active_support/notifications/instrumenter.rb:21:in `instrument'
vendor/bundle/gems/activesupport-3.1.1/lib/active_support/notifications.rb:53:in `instrument'
vendor/bundle/gems/actionpack-3.1.1/lib/action_view/renderer/abstract_renderer.rb:33:in `instrument'
vendor/bundle/gems/actionpack-3.1.1/lib/action_view/renderer/template_renderer.rb:39:in `render_template'
vendor/bundle/gems/actionpack-3.1.1/lib/action_view/renderer/template_renderer.rb:47:in `render_with_layout'
vendor/bundle/gems/actionpack-3.1.1/lib/action_view/renderer/template_renderer.rb:38:in `render_template'
vendor/bundle/gems/actionpack-3.1.1/lib/action_view/renderer/template_renderer.rb:12:in `render'
vendor/bundle/gems/actionpack-3.1.1/lib/action_view/renderer/abstract_renderer.rb:22:in `wrap_formats'
vendor/bundle/gems/actionpack-3.1.1/lib/action_view/renderer/template_renderer.rb:9:in `render'
vendor/bundle/gems/actionpack-3.1.1/lib/action_view/renderer/renderer.rb:36:in `render_template'
vendor/bundle/gems/actionpack-3.1.1/lib/action_view/renderer/renderer.rb:17:in `render'
vendor/bundle/gems/actionpack-3.1.1/lib/abstract_controller/rendering.rb:120:in `_render_template'
vendor/bundle/gems/actionpack-3.1.1/lib/action_controller/metal/streaming.rb:250:in `_render_template'
vendor/bundle/gems/actionpack-3.1.1/lib/abstract_controller/rendering.rb:114:in `render_to_body'
vendor/bundle/gems/actionpack-3.1.1/lib/action_controller/metal/renderers.rb:30:in `render_to_body'
vendor/bundle/gems/actionpack-3.1.1/lib/action_controller/metal/compatibility.rb:43:in `render_to_body'
vendor/bundle/gems/actionpack-3.1.1/lib/abstract_controller/rendering.rb:99:in `render'
vendor/bundle/gems/actionpack-3.1.1/lib/action_controller/metal/rendering.rb:16:in `render'
vendor/bundle/gems/actionpack-3.1.1/lib/action_controller/metal/instrumentation.rb:40:in `render'
vendor/bundle/gems/activesupport-3.1.1/lib/active_support/core_ext/benchmark.rb:5:in `ms'
/Users/roman/.rbenv/versions/1.8.7-p352/lib/ruby/1.8/benchmark.rb:308:in `realtime'
vendor/bundle/gems/activesupport-3.1.1/lib/active_support/core_ext/benchmark.rb:5:in `ms'
vendor/bundle/gems/actionpack-3.1.1/lib/action_controller/metal/instrumentation.rb:40:in `render'
vendor/bundle/gems/actionpack-3.1.1/lib/action_controller/metal/instrumentation.rb:78:in `cleanup_view_runtime'
vendor/bundle/gems/activerecord-3.1.1/lib/active_record/railties/controller_runtime.rb:24:in `cleanup_view_runtime'
vendor/bundle/gems/actionpack-3.1.1/lib/action_controller/metal/instrumentation.rb:39:in `render'
vendor/bundle/gems/actionpack-3.1.1/lib/action_controller/metal/implicit_render.rb:10:in `default_render'
vendor/bundle/gems/actionpack-3.1.1/lib/action_controller/metal/implicit_render.rb:4:in `send_action'
vendor/bundle/gems/actionpack-3.1.1/lib/action_controller/metal/implicit_render.rb:4:in `send_action'
vendor/bundle/gems/actionpack-3.1.1/lib/abstract_controller/base.rb:167:in `process_action'
vendor/bundle/gems/actionpack-3.1.1/lib/action_controller/metal/rendering.rb:10:in `process_action'
vendor/bundle/gems/actionpack-3.1.1/lib/abstract_controller/callbacks.rb:18:in `process_action'
vendor/bundle/gems/activesupport-3.1.1/lib/active_support/callbacks.rb:479:in `_run__34729210__process_action__1992409046__callbacks'
vendor/bundle/gems/activesupport-3.1.1/lib/active_support/callbacks.rb:386:in `send'
vendor/bundle/gems/activesupport-3.1.1/lib/active_support/callbacks.rb:386:in `_run_process_action_callbacks'
vendor/bundle/gems/activesupport-3.1.1/lib/active_support/callbacks.rb:81:in `send'
vendor/bundle/gems/activesupport-3.1.1/lib/active_support/callbacks.rb:81:in `run_callbacks'
vendor/bundle/gems/actionpack-3.1.1/lib/abstract_controller/callbacks.rb:17:in `process_action'
vendor/bundle/gems/actionpack-3.1.1/lib/action_controller/metal/rescue.rb:17:in `process_action'
vendor/bundle/gems/actionpack-3.1.1/lib/action_controller/metal/instrumentation.rb:30:in `process_action'
vendor/bundle/gems/activesupport-3.1.1/lib/active_support/notifications.rb:53:in `instrument'
vendor/bundle/gems/activesupport-3.1.1/lib/active_support/notifications/instrumenter.rb:21:in `instrument'
vendor/bundle/gems/activesupport-3.1.1/lib/active_support/notifications.rb:53:in `instrument'
vendor/bundle/gems/actionpack-3.1.1/lib/action_controller/metal/instrumentation.rb:29:in `process_action'
vendor/bundle/gems/actionpack-3.1.1/lib/action_controller/metal/params_wrapper.rb:201:in `process_action'
vendor/bundle/gems/activerecord-3.1.1/lib/active_record/railties/controller_runtime.rb:18:in `process_action'
vendor/bundle/gems/actionpack-3.1.1/lib/abstract_controller/base.rb:121:in `process'
vendor/bundle/gems/actionpack-3.1.1/lib/abstract_controller/rendering.rb:45:in `process'
vendor/bundle/gems/actionpack-3.1.1/lib/action_controller/metal.rb:193:in `dispatch'
vendor/bundle/gems/actionpack-3.1.1/lib/action_controller/metal/rack_delegation.rb:14:in `dispatch'
vendor/bundle/gems/actionpack-3.1.1/lib/action_controller/metal.rb:236:in `action'
vendor/bundle/gems/actionpack-3.1.1/lib/action_dispatch/routing/route_set.rb:65:in `call'
vendor/bundle/gems/actionpack-3.1.1/lib/action_dispatch/routing/route_set.rb:65:in `dispatch'
vendor/bundle/gems/actionpack-3.1.1/lib/action_dispatch/routing/route_set.rb:29:in `call'
vendor/bundle/gems/rack-mount-0.8.3/lib/rack/mount/route_set.rb:152:in `call'
vendor/bundle/gems/rack-mount-0.8.3/lib/rack/mount/code_generation.rb:96:in `recognize'
vendor/bundle/gems/rack-mount-0.8.3/lib/rack/mount/code_generation.rb:68:in `optimized_each'
vendor/bundle/gems/rack-mount-0.8.3/lib/rack/mount/code_generation.rb:95:in `recognize'
vendor/bundle/gems/rack-mount-0.8.3/lib/rack/mount/route_set.rb:141:in `call'
vendor/bundle/gems/actionpack-3.1.1/lib/action_dispatch/routing/route_set.rb:532:in `call'
vendor/bundle/bundler/gems/spree-81d257dcf847/core/lib/spree/core/middleware/redirect_legacy_product_url.rb:13:in `call'
vendor/bundle/bundler/gems/spree-81d257dcf847/core/lib/spree/core/middleware/seo_assist.rb:26:in `call'
vendor/bundle/gems/railties-3.1.1/lib/rails/engine.rb:456:in `call'
vendor/bundle/gems/railties-3.1.1/lib/rails/railtie/configurable.rb:30:in `send'
vendor/bundle/gems/railties-3.1.1/lib/rails/railtie/configurable.rb:30:in `method_missing'
vendor/bundle/gems/rack-mount-0.8.3/lib/rack/mount/prefix.rb:26:in `call'
vendor/bundle/gems/rack-mount-0.8.3/lib/rack/mount/route_set.rb:152:in `call'
vendor/bundle/gems/rack-mount-0.8.3/lib/rack/mount/code_generation.rb:96:in `recognize'
vendor/bundle/gems/rack-mount-0.8.3/lib/rack/mount/code_generation.rb:75:in `optimized_each'
vendor/bundle/gems/rack-mount-0.8.3/lib/rack/mount/code_generation.rb:95:in `recognize'
vendor/bundle/gems/rack-mount-0.8.3/lib/rack/mount/route_set.rb:141:in `call'
vendor/bundle/gems/actionpack-3.1.1/lib/action_dispatch/routing/route_set.rb:532:in `call'
vendor/bundle/gems/warden-1.0.6/lib/warden/manager.rb:35:in `call'
vendor/bundle/gems/warden-1.0.6/lib/warden/manager.rb:34:in `catch'
vendor/bundle/gems/warden-1.0.6/lib/warden/manager.rb:34:in `call'
vendor/bundle/gems/actionpack-3.1.1/lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
vendor/bundle/gems/rack-1.3.5/lib/rack/etag.rb:23:in `call'
vendor/bundle/gems/rack-1.3.5/lib/rack/conditionalget.rb:25:in `call'
vendor/bundle/gems/actionpack-3.1.1/lib/action_dispatch/middleware/head.rb:14:in `call'
vendor/bundle/gems/actionpack-3.1.1/lib/action_dispatch/middleware/params_parser.rb:21:in `call'
vendor/bundle/gems/actionpack-3.1.1/lib/action_dispatch/middleware/flash.rb:243:in `call'
vendor/bundle/gems/rack-1.3.5/lib/rack/session/abstract/id.rb:195:in `context'
vendor/bundle/gems/rack-1.3.5/lib/rack/session/abstract/id.rb:190:in `call'
vendor/bundle/gems/actionpack-3.1.1/lib/action_dispatch/middleware/cookies.rb:331:in `call'
vendor/bundle/gems/activerecord-3.1.1/lib/active_record/query_cache.rb:62:in `call'
vendor/bundle/gems/activerecord-3.1.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:477:in `call'
vendor/bundle/gems/actionpack-3.1.1/lib/action_dispatch/middleware/callbacks.rb:29:in `call'
vendor/bundle/gems/activesupport-3.1.1/lib/active_support/callbacks.rb:392:in `_run_call_callbacks'
vendor/bundle/gems/activesupport-3.1.1/lib/active_support/callbacks.rb:81:in `send'
vendor/bundle/gems/activesupport-3.1.1/lib/active_support/callbacks.rb:81:in `run_callbacks'
vendor/bundle/gems/actionpack-3.1.1/lib/action_dispatch/middleware/callbacks.rb:28:in `call'
vendor/bundle/gems/actionpack-3.1.1/lib/action_dispatch/middleware/reloader.rb:68:in `call'
vendor/bundle/gems/rack-1.3.5/lib/rack/sendfile.rb:101:in `call'
vendor/bundle/gems/actionpack-3.1.1/lib/action_dispatch/middleware/remote_ip.rb:48:in `call'
vendor/bundle/gems/actionpack-3.1.1/lib/action_dispatch/middleware/show_exceptions.rb:47:in `call'
vendor/bundle/gems/railties-3.1.1/lib/rails/rack/logger.rb:13:in `call'
vendor/bundle/gems/rack-1.3.5/lib/rack/methodoverride.rb:24:in `call'
vendor/bundle/gems/rack-1.3.5/lib/rack/runtime.rb:17:in `call'
vendor/bundle/gems/activesupport-3.1.1/lib/active_support/cache/strategy/local_cache.rb:72:in `call'
vendor/bundle/gems/rack-1.3.5/lib/rack/lock.rb:15:in `call'
vendor/bundle/gems/actionpack-3.1.1/lib/action_dispatch/middleware/static.rb:53:in `call'
vendor/bundle/gems/railties-3.1.1/lib/rails/engine.rb:456:in `call'
vendor/bundle/gems/railties-3.1.1/lib/rails/rack/content_length.rb:16:in `call'
vendor/bundle/gems/railties-3.1.1/lib/rails/rack/log_tailer.rb:14:in `call'
vendor/bundle/gems/rack-1.3.5/lib/rack/handler/webrick.rb:59:in `service'
/Users/roman/.rbenv/versions/1.8.7-p352/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
/Users/roman/.rbenv/versions/1.8.7-p352/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
/Users/roman/.rbenv/versions/1.8.7-p352/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
/Users/roman/.rbenv/versions/1.8.7-p352/lib/ruby/1.8/webrick/server.rb:162:in `start'
/Users/roman/.rbenv/versions/1.8.7-p352/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
/Users/roman/.rbenv/versions/1.8.7-p352/lib/ruby/1.8/webrick/server.rb:95:in `start'
/Users/roman/.rbenv/versions/1.8.7-p352/lib/ruby/1.8/webrick/server.rb:92:in `each'
/Users/roman/.rbenv/versions/1.8.7-p352/lib/ruby/1.8/webrick/server.rb:92:in `start'
/Users/roman/.rbenv/versions/1.8.7-p352/lib/ruby/1.8/webrick/server.rb:23:in `start'
/Users/roman/.rbenv/versions/1.8.7-p352/lib/ruby/1.8/webrick/server.rb:82:in `start'
vendor/bundle/gems/rack-1.3.5/lib/rack/handler/webrick.rb:13:in `run'
vendor/bundle/gems/rack-1.3.5/lib/rack/server.rb:265:in `start'
vendor/bundle/gems/railties-3.1.1/lib/rails/commands/server.rb:70:in `start'
vendor/bundle/gems/railties-3.1.1/lib/rails/commands.rb:54
vendor/bundle/gems/railties-3.1.1/lib/rails/commands.rb:49:in `tap'
vendor/bundle/gems/railties-3.1.1/lib/rails/commands.rb:49
script/rails:6:in `require'
script/rails:6
```

I tried to fix it with: shipping_method[:cost].to_f and that worked but I'm not sure if thats right.