开发者

Credit Card form with ActiveMerchant and Rails 3

using Rails 3 I can't get a form with with ActiveMerchant::Billing::CreditCard.new working as expected.

controller

@credit_card = ActiveMerchant::Billing::CreditCard.new

view

<%= form_for :credit_card, @credit_card do |f| %>
<%= f.text_field :first_name %>
<% end %>

Error

You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.any?

actionpack (3.0.4) lib/action_view/helpers/active_model_helper.rb:62:in `object_has_errors?'
actionpack (3.0.4) lib/action_view/helpers/active_model_helper.rb:48:in `error_wrapping'
actionpack (3.0.4) lib/action_view/helpers/active_model_helper.rb:44:in `tag'
actionpack (3.0.4) lib/action_view/helpers/form_helper.rb:918:in `to_input_field_tag'
actionpack (3.0.4) lib/action_view/helpers/form_helper.rb:625:in `text_field'
actionpack (3.0.4) lib/action_view/helpers/form_helper.rb:1131:in `send'
actionpack (3.0.4) lib/action_view/helpers/form_helper.rb:1131:in `text_field'
app/views/account/credit_card/edit.html.erb:8:in `_app_views_account_credit_card_edit_html_erb___109645858_2193109920_0'
actionpack (3.0.4) lib/action_view/helpers/capture_helper.rb:40:in `capture'
actionpack (3.0.4) lib/action_view/helpers/capture_helper.rb:172:in `with_output_buffer'
actionpack (3.0.4) lib/action_view/helpers/capture_helper.rb:40:in `capture'
actionpack (3.0.4) lib/action_view/helpers/form_helper.rb:544:in `fields_for'
actionpack (3.0.4) lib/action_view/helpers/form_helper.rb:320:in `form_for'
app/views/account/credit_card/edit.html.erb:7:in `_app_views_account_credit_card_edit_html_erb___109645858_2193109920_0'
actionpack (3.0.4) lib/action_view/template.rb:135:in `send'
actionpack (3.0.4) lib/action_view/template.rb:135:in `render'
activesupport (3.0.4) lib/active_support/notifications.rb:54:in `instrument'
actionpack (3.0.4) lib/action_view/template.rb:127:in `render'
actionpack (3.0.4) lib/action_view/render/rendering.rb:59:in `_render_template'
activesupport (3.0.4) lib/active_support/notifications.rb:52:in `instrument'
activesupport (3.0.4) lib/active_support/notifications/instrumenter.rb:21:in `instrument'
activesupport (3.0.4) lib/active_support/notifications.rb:52:in `instrument'
actionpack (3.0.4) lib/action_view/render/rendering.rb:56:in `_render_template'
actionpack (3.0.4) lib/action_view/render/rendering.rb:26:in `render'
actionpack (3.0.4) lib/abstract_controller/rendering.rb:115:in `_render_template'
actionpack (3.0.4) lib/abstract_controller/rendering.rb:109:in `render_to_body'
actionpack (3.0.4) lib/action_controller/metal/renderers.rb:47:in `render_to_body'
actionpack (3.0.4) lib/action_controller/metal/compatibility.rb:55:in `render_to_body'
actionpack (3.0.4) lib/abstract_controller/rendering.rb:102:in `render_to_string'
actionpack (3.0.4) lib/abstract_controller/rendering.rb:93:in `render'
actionpack (3.0.4) lib/action_controller/metal/rendering.rb:17:in `render'
actionpack (3.0.4) lib/action_controller/metal/instrumentation.rb:40:in `render_without_wicked_pdf'
activesupport (3.0.4) lib/active_support/core_ext/benchmark.rb:5:in `ms'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/benchmark.rb:308:in `realtime'
activesupport (3.0.4) lib/active_support/core_ext/benchmark.rb:5:in `ms'
actionpack (3.0.4) lib/action_controller/metal/instrumentation.rb:40:in `render_without_wicked_pdf'
actionpack (3.0.4) lib/action_controller/metal/instrumentation.rb:78:in `cleanup_view_runtime'
activerecord (3.0.4) lib/active_record/railties/controller_runtime.rb:15:in `cleanup_view_runtime'
actionpack (3.0.4) lib/action_controller/metal/instrumentation.rb:39:in `render_without_wicked_pdf'
vendor/plugins/wicked_pdf/lib/pdf_helper.rb:15:in `render'
actionpack (3.0.4) lib/action_controller/metal/implicit_render.rb:10:in `default_render'
actionpack (3.0.4) lib/action_controller/metal/implicit_render.rb:5:in `send_action'
actionpack (3.0.4) lib/abstract_controller/base.rb:150:in `process_action'
actionpack (3.0.4) lib/action_controller/metal/rendering.rb:11:in `process_action'
actionpack (3.0.4) lib/abstract_controller/callbacks.rb:18:in `process_action'
activesupport (3.0.4) lib/active_support/callbacks.rb:485:in `_run__210577272__process_action__1992409046__callbacks'
activesupport (3.0.4) lib/active_support/callbacks.rb:开发者_JS百科409:in `send'
activesupport (3.0.4) lib/active_support/callbacks.rb:409:in `_run_process_action_callbacks'
activesupport (3.0.4) lib/active_support/callbacks.rb:93:in `send'
activesupport (3.0.4) lib/active_support/callbacks.rb:93:in `run_callbacks'
actionpack (3.0.4) lib/abstract_controller/callbacks.rb:17:in `process_action'
actionpack (3.0.4) lib/action_controller/metal/instrumentation.rb:30:in `process_action'
activesupport (3.0.4) lib/active_support/notifications.rb:52:in `instrument'
activesupport (3.0.4) lib/active_support/notifications/instrumenter.rb:21:in `instrument'
activesupport (3.0.4) lib/active_support/notifications.rb:52:in `instrument'
actionpack (3.0.4) lib/action_controller/metal/instrumentation.rb:29:in `process_action'
actionpack (3.0.4) lib/action_controller/metal/rescue.rb:17:in `process_action'
actionpack (3.0.4) lib/abstract_controller/base.rb:119:in `process'
actionpack (3.0.4) lib/abstract_controller/rendering.rb:41:in `process'
actionpack (3.0.4) lib/action_controller/metal.rb:138:in `dispatch'
actionpack (3.0.4) lib/action_controller/metal/rack_delegation.rb:14:in `dispatch'
actionpack (3.0.4) lib/action_controller/metal.rb:178:in `action'
actionpack (3.0.4) lib/action_dispatch/routing/route_set.rb:62:in `call'
actionpack (3.0.4) lib/action_dispatch/routing/route_set.rb:62:in `dispatch'
actionpack (3.0.4) lib/action_dispatch/routing/route_set.rb:27:in `call'
rack-mount (0.6.13) lib/rack/mount/route_set.rb:148:in `call'
routing-filter (0.2.3) lib/routing_filter/adapters/rails_3.rb:74:in `recognize'
rack-mount (0.6.13) lib/rack/mount/route_set.rb:139:in `call'
actionpack (3.0.4) lib/action_dispatch/routing/route_set.rb:492:in `call'
exception_notification_rails3 (1.2.0) lib/exception_notifier.rb:34:in `call'
warden (1.0.3) lib/warden/manager.rb:35:in `call'
warden (1.0.3) lib/warden/manager.rb:34:in `catch'
warden (1.0.3) lib/warden/manager.rb:34:in `call'
actionpack (3.0.4) lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
actionpack (3.0.4) lib/action_dispatch/middleware/head.rb:14:in `call'
rack (1.2.1) lib/rack/methodoverride.rb:24:in `call'
actionpack (3.0.4) lib/action_dispatch/middleware/params_parser.rb:21:in `call'
actionpack (3.0.4) lib/action_dispatch/middleware/flash.rb:182:in `call'
actionpack (3.0.4) lib/action_dispatch/middleware/session/abstract_store.rb:149:in `call'
actionpack (3.0.4) lib/action_dispatch/middleware/cookies.rb:302:in `call'
activerecord (3.0.4) lib/active_record/query_cache.rb:32:in `call'
activerecord (3.0.4) lib/active_record/connection_adapters/abstract/query_cache.rb:28:in `cache'
activerecord (3.0.4) lib/active_record/query_cache.rb:12:in `cache'
activerecord (3.0.4) lib/active_record/query_cache.rb:31:in `call'
activerecord (3.0.4) lib/active_record/connection_adapters/abstract/connection_pool.rb:354:in `call'
actionpack (3.0.4) lib/action_dispatch/middleware/callbacks.rb:46:in `call'
activesupport (3.0.4) lib/active_support/callbacks.rb:415:in `_run_call_callbacks'
actionpack (3.0.4) lib/action_dispatch/middleware/callbacks.rb:44:in `call'
rack (1.2.1) lib/rack/sendfile.rb:107:in `call'
actionpack (3.0.4) lib/action_dispatch/middleware/remote_ip.rb:48:in `call'
actionpack (3.0.4) lib/action_dispatch/middleware/show_exceptions.rb:47:in `call'
railties (3.0.4) lib/rails/rack/logger.rb:13:in `call'
rack (1.2.1) lib/rack/runtime.rb:17:in `call'
activesupport (3.0.4) lib/active_support/cache/strategy/local_cache.rb:72:in `call'
rack (1.2.1) lib/rack/lock.rb:11:in `call'
rack (1.2.1) lib/rack/lock.rb:11:in `synchronize'
rack (1.2.1) lib/rack/lock.rb:11:in `call'
actionpack (3.0.4) lib/action_dispatch/middleware/static.rb:30:in `call'
railties (3.0.4) lib/rails/application.rb:168:in `call'
railties (3.0.4) lib/rails/application.rb:77:in `send'
railties (3.0.4) lib/rails/application.rb:77:in `method_missing'
passenger (3.0.2) lib/phusion_passenger/rack/request_handler.rb:96:in `process_request'
passenger (3.0.2) lib/phusion_passenger/abstract_request_handler.rb:513:in `accept_and_process_next_request'
passenger (3.0.2) lib/phusion_passenger/abstract_request_handler.rb:274:in `main_loop'
passenger (3.0.2) lib/phusion_passenger/rack/application_spawner.rb:205:in `start_request_handler'
passenger (3.0.2) lib/phusion_passenger/rack/application_spawner.rb:170:in `send'
passenger (3.0.2) lib/phusion_passenger/rack/application_spawner.rb:170:in `handle_spawn_application'
passenger (3.0.2) lib/phusion_passenger/utils.rb:479:in `safe_fork'
passenger (3.0.2) lib/phusion_passenger/rack/application_spawner.rb:165:in `handle_spawn_application'
passenger (3.0.2) lib/phusion_passenger/abstract_server.rb:357:in `__send__'
passenger (3.0.2) lib/phusion_passenger/abstract_server.rb:357:in `server_main_loop'
passenger (3.0.2) lib/phusion_passenger/abstract_server.rb:206:in `start_synchronously'
passenger (3.0.2) lib/phusion_passenger/abstract_server.rb:180:in `start'
passenger (3.0.2) lib/phusion_passenger/rack/application_spawner.rb:128:in `start'
passenger (3.0.2) lib/phusion_passenger/spawn_manager.rb:253:in `spawn_rack_application'
passenger (3.0.2) lib/phusion_passenger/abstract_server_collection.rb:132:in `lookup_or_add'
passenger (3.0.2) lib/phusion_passenger/spawn_manager.rb:246:in `spawn_rack_application'
passenger (3.0.2) lib/phusion_passenger/abstract_server_collection.rb:82:in `synchronize'
passenger (3.0.2) lib/phusion_passenger/abstract_server_collection.rb:79:in `synchronize'
passenger (3.0.2) lib/phusion_passenger/spawn_manager.rb:244:in `spawn_rack_application'
passenger (3.0.2) lib/phusion_passenger/spawn_manager.rb:137:in `spawn_application'
passenger (3.0.2) lib/phusion_passenger/spawn_manager.rb:275:in `handle_spawn_application'
passenger (3.0.2) lib/phusion_passenger/abstract_server.rb:357:in `__send__'
passenger (3.0.2) lib/phusion_passenger/abstract_server.rb:357:in `server_main_loop'
passenger (3.0.2) lib/phusion_passenger/abstract_server.rb:206:in `start_synchronously'
passenger (3.0.2) helper-scripts/passenger-spawn-server:99

I do not use any form builder while getting this error. Is there a different way to do this ?


You can hack your way through this:

https://github.com/Shopify/active_merchant/pull/33

Shopify team says fix won't be in until ActiveMerchant 2.0

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜