heartcombo / simple_form

Forms made easy for Rails! It's tied to a simple DSL, with no opinion on markup.
http://blog.plataformatec.com.br/tag/simple_form
MIT License
8.21k stars 1.31k forks source link

radion_buttons error : wrong number of arguments (6 for 3) #694

Closed openxyz closed 11 years ago

openxyz commented 11 years ago

code:

= simple_form_for @article do |f| 
   = f.association :user, :as => :radio_buttons

when i update to simple_form 2.04 and rails 3.2.9, get the error message as below:

wrong number of arguments (6 for 3)

trace:
actionpack (3.2.9) lib/action_view/helpers/form_helper.rb:953:in `instantiate_builder'
simple_form (2.0.4) lib/simple_form/action_view_extensions/builder.rb:95:in `block in collection_radio_buttons'
simple_form (2.0.4) lib/simple_form/action_view_extensions/builder.rb:253:in `block in render_collection'

it seems SimpleForm::ActionViewExtensions::Builder#instantiate_builder can not work or did not included in ActionView::Helpers::FormBuilder

how to slove it ?

nashby commented 11 years ago

@openxyz I've just tried it in a new rails 3.2.9 application and can't reproduce it. Could you please create a simple application that reproduces this issue and push it to github?

carlosantoniodasilva commented 11 years ago

Our instantiate_builder method might be colliding with the Rails' one, we could rename our method to something like instantiate_collection_builder.

nashby commented 11 years ago

@carlosantoniodasilva yeah, probably. I'm just wondering why it works with new rails app...

carlosantoniodasilva commented 11 years ago

Dunno, something else may be in the way here. Also, I think those two methods I sent before operate in different scopes, ours work within the FormBuilder, Rails' one operates inside the Helpers.

@openxyz can you show the full stack and also your Gemfile? Thanks.

openxyz commented 11 years ago

my Gemfile

gem 'rails',  '3.2.9'
gem 'execjs'
gem 'therubyracer'

group :assets do
  gem 'sass-rails', "~> 3.2.0"
  gem 'coffee-rails', "~> 3.2.0"
  gem 'uglifier'
  gem 'compass','~> 0.12.alpha'
  gem 'compass-rails'
  gem 'jquery-rails'
  gem 'bootstrap-sass',
    :git => 'git://github.com/thomas-mcdonald/bootstrap-sass'
end

group :development do
  gem 'linecache19', :git => 'git://github.com/mark-moseley/linecache'
  gem 'ruby-debug-base19x', '~> 0.11.30.pre4'
  gem 'ruby-debug19'
  #gem 'rails-dev-tweaks', '~> 0.5.1'
  gem 'irbtools', :require => false
  gem 'capistrano'
end

group :production do
  gem 'mysql2'
  gem 'unicorn'
end

gem 'sqlite3'

gem 'inherited_resources'
gem 'devise'
gem 'cancan'

gem 'bitmask_attributes'
gem "ransack",:git => "git://github.com/ernie/ransack.git"

gem 'cells'
gem 'haml-rails'
gem 'simple_form'
gem 'nested_form',   :git => 'git://github.com/ryanb/nested_form'
gem "rails-settings-cached"

gem "carrierwave"
#gem "plupload-rails", :git => 'git://github.com/gucki/plupload-rails'

gem "mini_magick"
gem "kaminari"
gem "galetahub-simple_captcha", :require => "simple_captcha",:git => 'git://github.com/galetahub/simple-captcha.git'

gem "rails_kindeditor"

gem "with_action"
gem 'workflow'
gem 'make_flaggable', :git => 'git://github.com/openxyz/make_flaggable'

gem 'switch_user'

group :test do
  # Pretty printed test output
  gem 'turn', :require => false
  gem "mocha"
end
openxyz commented 11 years ago

@carlosantoniodasilva what do you mean the full stack?

nashby commented 11 years ago

@openxyz he means full stack trace, not just last 3 lines. This will help a lot. Thanks!

openxyz commented 11 years ago
actionpack (3.2.9) lib/action_view/helpers/form_helper.rb:953:in `instantiate_builder'
simple_form (2.0.4) lib/simple_form/action_view_extensions/builder.rb:95:in `block in collection_radio_buttons'
simple_form (2.0.4) lib/simple_form/action_view_extensions/builder.rb:253:in `block in render_collection'
simple_form (2.0.4) lib/simple_form/action_view_extensions/builder.rb:248:in `map'
simple_form (2.0.4) lib/simple_form/action_view_extensions/builder.rb:248:in `render_collection'
simple_form (2.0.4) lib/simple_form/action_view_extensions/builder.rb:93:in `collection_radio_buttons'
simple_form (2.0.4) lib/simple_form/inputs/collection_radio_buttons_input.rb:7:in `input'
simple_form (2.0.4) lib/simple_form/wrappers/many.rb:29:in `block in render'
simple_form (2.0.4) lib/simple_form/wrappers/many.rb:27:in `each'
simple_form (2.0.4) lib/simple_form/wrappers/many.rb:27:in `render'
simple_form (2.0.4) lib/simple_form/wrappers/many.rb:29:in `block in render'
simple_form (2.0.4) lib/simple_form/wrappers/many.rb:27:in `each'
simple_form (2.0.4) lib/simple_form/wrappers/many.rb:27:in `render'
simple_form (2.0.4) lib/simple_form/wrappers/root.rb:15:in `render'
simple_form (2.0.4) lib/simple_form/form_builder.rb:116:in `input'
app/views/admin/work_certs/_form.html.haml:7:in `block (2 levels) in _app_views_admin_work_certs__form_html_haml__922982793_84026650'
haml (3.1.7) lib/haml/helpers/action_view_mods.rb:93:in `block in capture_with_haml'
haml (3.1.7) lib/haml/helpers.rb:345:in `call'
haml (3.1.7) lib/haml/helpers.rb:345:in `block in capture_haml'
haml (3.1.7) lib/haml/helpers.rb:569:in `with_haml_buffer'
haml (3.1.7) lib/haml/helpers.rb:341:in `capture_haml'
haml (3.1.7) lib/haml/helpers/xss_mods.rb:61:in `capture_haml_with_haml_xss'
haml (3.1.7) lib/haml/helpers/action_view_mods.rb:93:in `capture_with_haml'
actionpack (3.2.9) lib/action_view/helpers/form_tag_helper.rb:537:in `field_set_tag'
app/views/admin/work_certs/_form.html.haml:4:in `block in _app_views_admin_work_certs__form_html_haml__922982793_84026650'
haml (3.1.7) lib/haml/helpers/action_view_mods.rb:93:in `block in capture_with_haml'
haml (3.1.7) lib/haml/helpers.rb:345:in `call'
haml (3.1.7) lib/haml/helpers.rb:345:in `block in capture_haml'
haml (3.1.7) lib/haml/helpers.rb:569:in `with_haml_buffer'
haml (3.1.7) lib/haml/helpers.rb:341:in `capture_haml'
haml (3.1.7) lib/haml/helpers/xss_mods.rb:61:in `capture_haml_with_haml_xss'
haml (3.1.7) lib/haml/helpers/action_view_mods.rb:93:in `capture_with_haml'
/home/afly/.rvm/gems/ruby-1.9.3-p125@zjhwrc/bundler/gems/nested_form-b790a362b1b7/lib/nested_form/view_helper.rb:16:in `block in simple_nested_form_for'
actionpack (3.2.9) lib/action_view/helpers/capture_helper.rb:40:in `block in capture'
actionpack (3.2.9) lib/action_view/helpers/capture_helper.rb:187:in `with_output_buffer'
haml (3.1.7) lib/haml/helpers/xss_mods.rb:109:in `with_output_buffer_with_haml_xss'
actionpack (3.2.9) lib/action_view/helpers/capture_helper.rb:40:in `capture'
haml (3.1.7) lib/haml/helpers/action_view_mods.rb:105:in `capture_with_haml'
actionpack (3.2.9) lib/action_view/helpers/form_helper.rb:607:in `fields_for'
actionpack (3.2.9) lib/action_view/helpers/form_helper.rb:378:in `form_for'
haml (3.1.7) lib/haml/helpers/action_view_mods.rb:183:in `form_for_with_haml'
haml (3.1.7) lib/haml/helpers/xss_mods.rb:132:in `form_for_with_haml_xss'
simple_form (2.0.4) lib/simple_form/action_view_extensions/form_helper.rb:29:in `block in simple_form_for'
simple_form (2.0.4) lib/simple_form/action_view_extensions/form_helper.rb:48:in `with_simple_form_field_error_proc'
simple_form (2.0.4) lib/simple_form/action_view_extensions/form_helper.rb:28:in `simple_form_for'
/home/afly/.rvm/gems/ruby-1.9.3-p125@zjhwrc/bundler/gems/nested_form-b790a362b1b7/lib/nested_form/view_helper.rb:15:in `simple_nested_form_for'
app/views/admin/work_certs/_form.html.haml:1:in `_app_views_admin_work_certs__form_html_haml__922982793_84026650'
actionpack (3.2.9) lib/action_view/template.rb:145:in `block in render'
activesupport (3.2.9) lib/active_support/notifications.rb:125:in `instrument'
actionpack (3.2.9) lib/action_view/template.rb:143:in `render'
actionpack (3.2.9) lib/action_view/renderer/partial_renderer.rb:265:in `render_partial'
actionpack (3.2.9) lib/action_view/renderer/partial_renderer.rb:238:in `block in render'
actionpack (3.2.9) lib/action_view/renderer/abstract_renderer.rb:38:in `block in instrument'
activesupport (3.2.9) lib/active_support/notifications.rb:123:in `block in instrument'
activesupport (3.2.9) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (3.2.9) lib/active_support/notifications.rb:123:in `instrument'
actionpack (3.2.9) lib/action_view/renderer/abstract_renderer.rb:38:in `instrument'
actionpack (3.2.9) lib/action_view/renderer/partial_renderer.rb:237:in `render'
actionpack (3.2.9) lib/action_view/renderer/renderer.rb:41:in `render_partial'
actionpack (3.2.9) lib/action_view/helpers/rendering_helper.rb:27:in `render'
haml (3.1.7) lib/haml/helpers/action_view_mods.rb:11:in `block in render_with_haml'
haml (3.1.7) lib/haml/helpers.rb:90:in `non_haml'
haml (3.1.7) lib/haml/helpers/action_view_mods.rb:11:in `render_with_haml'
app/views/admin/work_certs/edit.html.haml:3:in `_app_views_admin_work_certs_edit_html_haml__1023545990_89819620'
actionpack (3.2.9) lib/action_view/template.rb:145:in `block in render'
activesupport (3.2.9) lib/active_support/notifications.rb:125:in `instrument'
actionpack (3.2.9) lib/action_view/template.rb:143:in `render'
actionpack (3.2.9) lib/action_view/renderer/template_renderer.rb:47:in `block (2 levels) in render_template'
actionpack (3.2.9) lib/action_view/renderer/abstract_renderer.rb:38:in `block in instrument'
activesupport (3.2.9) lib/active_support/notifications.rb:123:in `block in instrument'
activesupport (3.2.9) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (3.2.9) lib/active_support/notifications.rb:123:in `instrument'
actionpack (3.2.9) lib/action_view/renderer/abstract_renderer.rb:38:in `instrument'
actionpack (3.2.9) lib/action_view/renderer/template_renderer.rb:46:in `block in render_template'
actionpack (3.2.9) lib/action_view/renderer/template_renderer.rb:54:in `render_with_layout'
actionpack (3.2.9) lib/action_view/renderer/template_renderer.rb:45:in `render_template'
actionpack (3.2.9) lib/action_view/renderer/template_renderer.rb:18:in `render'
actionpack (3.2.9) lib/action_view/renderer/renderer.rb:36:in `render_template'
actionpack (3.2.9) lib/action_view/renderer/renderer.rb:17:in `render'
actionpack (3.2.9) lib/abstract_controller/rendering.rb:110:in `_render_template'
actionpack (3.2.9) lib/action_controller/metal/streaming.rb:225:in `_render_template'
actionpack (3.2.9) lib/abstract_controller/rendering.rb:103:in `render_to_body'
actionpack (3.2.9) lib/action_controller/metal/renderers.rb:28:in `render_to_body'
actionpack (3.2.9) lib/action_controller/metal/compatibility.rb:50:in `render_to_body'
actionpack (3.2.9) lib/abstract_controller/rendering.rb:88:in `render'
actionpack (3.2.9) lib/action_controller/metal/rendering.rb:16:in `render'
actionpack (3.2.9) lib/action_controller/metal/instrumentation.rb:40:in `block (2 levels) in render'
activesupport (3.2.9) lib/active_support/core_ext/benchmark.rb:5:in `block in ms'
/home/afly/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/benchmark.rb:295:in `realtime'
activesupport (3.2.9) lib/active_support/core_ext/benchmark.rb:5:in `ms'
actionpack (3.2.9) lib/action_controller/metal/instrumentation.rb:40:in `block in render'
actionpack (3.2.9) lib/action_controller/metal/instrumentation.rb:83:in `cleanup_view_runtime'
activerecord (3.2.9) lib/active_record/railties/controller_runtime.rb:24:in `cleanup_view_runtime'
actionpack (3.2.9) lib/action_controller/metal/instrumentation.rb:39:in `render'
actionpack (3.2.9) lib/action_controller/metal/implicit_render.rb:10:in `default_render'
actionpack (3.2.9) lib/action_controller/metal/responder.rb:232:in `default_render'
actionpack (3.2.9) lib/action_controller/metal/responder.rb:160:in `to_html'
responders (0.9.3) lib/responders/flash_responder.rb:104:in `to_html'
actionpack (3.2.9) lib/action_controller/metal/responder.rb:153:in `respond'
actionpack (3.2.9) lib/action_controller/metal/responder.rb:146:in `call'
actionpack (3.2.9) lib/action_controller/metal/mime_responds.rb:239:in `respond_with'
inherited_resources (1.3.1) lib/inherited_resources/actions.rb:25:in `edit'
actionpack (3.2.9) lib/action_controller/metal/implicit_render.rb:4:in `send_action'
actionpack (3.2.9) lib/abstract_controller/base.rb:167:in `process_action'
actionpack (3.2.9) lib/action_controller/metal/rendering.rb:10:in `process_action'
actionpack (3.2.9) lib/abstract_controller/callbacks.rb:18:in `block in process_action'
activesupport (3.2.9) lib/active_support/callbacks.rb:447:in `_run__171164530__process_action__321006347__callbacks'
activesupport (3.2.9) lib/active_support/callbacks.rb:405:in `__run_callback'
activesupport (3.2.9) lib/active_support/callbacks.rb:385:in `_run_process_action_callbacks'
activesupport (3.2.9) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (3.2.9) lib/abstract_controller/callbacks.rb:17:in `process_action'
actionpack (3.2.9) lib/action_controller/metal/rescue.rb:29:in `process_action'
actionpack (3.2.9) lib/action_controller/metal/instrumentation.rb:30:in `block in process_action'
activesupport (3.2.9) lib/active_support/notifications.rb:123:in `block in instrument'
activesupport (3.2.9) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (3.2.9) lib/active_support/notifications.rb:123:in `instrument'
actionpack (3.2.9) lib/action_controller/metal/instrumentation.rb:29:in `process_action'
actionpack (3.2.9) lib/action_controller/metal/params_wrapper.rb:207:in `process_action'
activerecord (3.2.9) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
actionpack (3.2.9) lib/abstract_controller/base.rb:121:in `process'
actionpack (3.2.9) lib/abstract_controller/rendering.rb:45:in `process'
actionpack (3.2.9) lib/action_controller/metal.rb:203:in `dispatch'
actionpack (3.2.9) lib/action_controller/metal/rack_delegation.rb:14:in `dispatch'
actionpack (3.2.9) lib/action_controller/metal.rb:246:in `block in action'
actionpack (3.2.9) lib/action_dispatch/routing/route_set.rb:73:in `call'
actionpack (3.2.9) lib/action_dispatch/routing/route_set.rb:73:in `dispatch'
actionpack (3.2.9) lib/action_dispatch/routing/route_set.rb:36:in `call'
journey (1.0.4) lib/journey/router.rb:68:in `block in call'
journey (1.0.4) lib/journey/router.rb:56:in `each'
journey (1.0.4) lib/journey/router.rb:56:in `call'
actionpack (3.2.9) lib/action_dispatch/routing/route_set.rb:601:in `call'
/home/afly/.rvm/gems/ruby-1.9.3-p125@zjhwrc/bundler/gems/simple-captcha-a0c997c109c3/lib/simple_captcha/middleware.rb:20:in `call'
warden (1.2.1) lib/warden/manager.rb:35:in `block in call'
warden (1.2.1) lib/warden/manager.rb:34:in `catch'
warden (1.2.1) lib/warden/manager.rb:34:in `call'
actionpack (3.2.9) lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
rack (1.4.1) lib/rack/etag.rb:23:in `call'
rack (1.4.1) lib/rack/conditionalget.rb:25:in `call'
actionpack (3.2.9) lib/action_dispatch/middleware/head.rb:14:in `call'
actionpack (3.2.9) lib/action_dispatch/middleware/params_parser.rb:21:in `call'
actionpack (3.2.9) lib/action_dispatch/middleware/flash.rb:242:in `call'
rack (1.4.1) lib/rack/session/abstract/id.rb:205:in `context'
rack (1.4.1) lib/rack/session/abstract/id.rb:200:in `call'
actionpack (3.2.9) lib/action_dispatch/middleware/cookies.rb:341:in `call'
activerecord (3.2.9) lib/active_record/query_cache.rb:64:in `call'
activerecord (3.2.9) lib/active_record/connection_adapters/abstract/connection_pool.rb:479:in `call'
actionpack (3.2.9) lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'
activesupport (3.2.9) lib/active_support/callbacks.rb:405:in `_run__143889063__call__510457517__callbacks'
activesupport (3.2.9) lib/active_support/callbacks.rb:405:in `__run_callback'
activesupport (3.2.9) lib/active_support/callbacks.rb:385:in `_run_call_callbacks'
activesupport (3.2.9) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (3.2.9) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
actionpack (3.2.9) lib/action_dispatch/middleware/reloader.rb:65:in `call'
actionpack (3.2.9) lib/action_dispatch/middleware/remote_ip.rb:31:in `call'
actionpack (3.2.9) lib/action_dispatch/middleware/debug_exceptions.rb:16:in `call'
actionpack (3.2.9) lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
railties (3.2.9) lib/rails/rack/logger.rb:32:in `call_app'
railties (3.2.9) lib/rails/rack/logger.rb:16:in `block in call'
activesupport (3.2.9) lib/active_support/tagged_logging.rb:22:in `tagged'
railties (3.2.9) lib/rails/rack/logger.rb:16:in `call'
config/initializers/quiet_assets.rb:7:in `call_with_quiet_assets'
actionpack (3.2.9) lib/action_dispatch/middleware/request_id.rb:22:in `call'
rack (1.4.1) lib/rack/methodoverride.rb:21:in `call'
rack (1.4.1) lib/rack/runtime.rb:17:in `call'
activesupport (3.2.9) lib/active_support/cache/strategy/local_cache.rb:72:in `call'
rack (1.4.1) lib/rack/lock.rb:15:in `call'
actionpack (3.2.9) lib/action_dispatch/middleware/static.rb:62:in `call'
railties (3.2.9) lib/rails/engine.rb:479:in `call'
railties (3.2.9) lib/rails/application.rb:223:in `call'
rack (1.4.1) lib/rack/content_length.rb:14:in `call'
railties (3.2.9) lib/rails/rack/log_tailer.rb:17:in `call'
rack (1.4.1) lib/rack/handler/webrick.rb:59:in `service'
/home/afly/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/webrick/httpserver.rb:138:in `service'
/home/afly/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/webrick/httpserver.rb:94:in `run'
/home/afly/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/webrick/server.rb:191:in `block in start_thread'
openxyz commented 11 years ago

for now i just slove it as carlosantoniodasilva suggest https://github.com/plataformatec/simple_form/issues/694#issuecomment-10488116 : replace all "instantiate_builder" with "instantiate_collection_builder" in build.rb

nashby commented 11 years ago

well, I figured it out. There is a problem with simple-captch here https://github.com/galetahub/simple-captcha/blob/master/lib/simple_captcha/form_builder.rb#L6. @carlosantoniodasilva as you can see it includes ActionView::Helpers to ActionView::Helpers::FormBuilder that redefines instantiate_builder. I have no idea why it was made like this =\ Any thoughts? :sweat:

carlosantoniodasilva commented 11 years ago

@nashby maybe to call these without calling through the template? Otherwise, :bomb:

nashby commented 11 years ago

@carlosantoniodasilva yeah, looks so. Unfortunately that project has only one test https://github.com/galetahub/simple-captcha/blob/master/test/simple_captcha_test.rb so it will be not so easy to fix it :( I'll try to give it a shot anyway.

AnandChronus commented 10 years ago

Can this patch be applied on v2.0 branch as well?

AnandChronus commented 10 years ago

Can this patch be applied on v2.0 branch as well?