Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ArgumentError (wrong number of arguments (given 4, expected 3)) #948

Closed
LucasCioffi opened this issue Aug 11, 2018 · 5 comments
Closed

ArgumentError (wrong number of arguments (given 4, expected 3)) #948

LucasCioffi opened this issue Aug 11, 2018 · 5 comments

Comments

@LucasCioffi
Copy link

Hello, I was getting ArgumentError (wrong number of arguments (given 4, expected 3)) on an ActiveAdmin index page where Ransack was used for filters in a sidebar menu.

Rails 5.2.1
ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-darwin17]

To get past it, I had to change this:
join_dependency = JoinDependency.new(relation.klass, relation.table, association_joins, alias_tracker)
to this:
JoinDependency.new(relation.klass, relation.table, association_joins, alias_tracker)

Log

ArgumentError (wrong number of arguments (given 4, expected 3)):
  
activerecord (5.2.1) lib/active_record/associations/join_dependency.rb:70:in `initialize'
ransack (1.8.8) lib/ransack/adapters/active_record/context.rb:294:in `new'
ransack (1.8.8) lib/ransack/adapters/active_record/context.rb:294:in `build_joins'
ransack (1.8.8) lib/ransack/adapters/active_record/context.rb:247:in `join_dependency'
ransack (1.8.8) lib/ransack/adapters/active_record/ransack/context.rb:27:in `initialize'
ransack (1.8.8) lib/ransack/adapters/active_record/context.rb:16:in `initialize'
ransack (1.8.8) lib/ransack/adapters/active_record/ransack/context.rb:11:in `new'
ransack (1.8.8) lib/ransack/adapters/active_record/ransack/context.rb:11:in `for_class'
ransack (1.8.8) lib/ransack/context.rb:22:in `for'
ransack (1.8.8) lib/ransack/search.rb:25:in `initialize'
ransack (1.8.8) lib/ransack/adapters/active_record/base.rb:17:in `new'
ransack (1.8.8) lib/ransack/adapters/active_record/base.rb:17:in `ransack'
activerecord (5.2.1) lib/active_record/relation/delegation.rb:84:in `public_send'
activerecord (5.2.1) lib/active_record/relation/delegation.rb:84:in `block in method_missing'
activerecord (5.2.1) lib/active_record/relation.rb:281:in `scoping'
activerecord (5.2.1) lib/active_record/relation/delegation.rb:84:in `method_missing'
activeadmin (1.3.0) lib/active_admin/resource_controller/data_access.rb:217:in `apply_filtering'
activeadmin (1.3.0) lib/active_admin/resource_controller/data_access.rb:59:in `block in find_collection'
activeadmin (1.3.0) lib/active_admin/resource_controller/data_access.rb:58:in `each'
activeadmin (1.3.0) lib/active_admin/resource_controller/data_access.rb:58:in `find_collection'
activeadmin (1.3.0) lib/active_admin/resource_controller/data_access.rb:44:in `collection'
inherited_resources (1.9.0) lib/inherited_resources/actions.rb:7:in `index'
activeadmin (1.3.0) lib/active_admin/resource_controller/streaming.rb:12:in `index'
actionpack (5.2.1) lib/action_controller/metal/basic_implicit_render.rb:6:in `send_action'
actionpack (5.2.1) lib/abstract_controller/base.rb:194:in `process_action'
actionpack (5.2.1) lib/action_controller/metal/rendering.rb:30:in `process_action'
actionpack (5.2.1) lib/abstract_controller/callbacks.rb:42:in `block in process_action'
activesupport (5.2.1) lib/active_support/callbacks.rb:132:in `run_callbacks'
actionpack (5.2.1) lib/abstract_controller/callbacks.rb:41:in `process_action'
actionpack (5.2.1) lib/action_controller/metal/rescue.rb:22:in `process_action'
actionpack (5.2.1) lib/action_controller/metal/instrumentation.rb:34:in `block in process_action'
activesupport (5.2.1) lib/active_support/notifications.rb:168:in `block in instrument'
activesupport (5.2.1) lib/active_support/notifications/instrumenter.rb:23:in `instrument'
activesupport (5.2.1) lib/active_support/notifications.rb:168:in `instrument'
actionpack (5.2.1) lib/action_controller/metal/instrumentation.rb:32:in `process_action'
actionpack (5.2.1) lib/action_controller/metal/params_wrapper.rb:256:in `process_action'
activerecord (5.2.1) lib/active_record/railties/controller_runtime.rb:24:in `process_action'
actionpack (5.2.1) lib/abstract_controller/base.rb:134:in `process'
actionview (5.2.1) lib/action_view/rendering.rb:32:in `process'
actionpack (5.2.1) lib/action_controller/metal.rb:191:in `dispatch'
actionpack (5.2.1) lib/action_controller/metal.rb:252:in `dispatch'
actionpack (5.2.1) lib/action_dispatch/routing/route_set.rb:52:in `dispatch'
actionpack (5.2.1) lib/action_dispatch/routing/route_set.rb:34:in `serve'
actionpack (5.2.1) lib/action_dispatch/journey/router.rb:52:in `block in serve'
actionpack (5.2.1) lib/action_dispatch/journey/router.rb:35:in `each'
actionpack (5.2.1) lib/action_dispatch/journey/router.rb:35:in `serve'
actionpack (5.2.1) lib/action_dispatch/routing/route_set.rb:840:in `call'
warden (1.2.7) lib/warden/manager.rb:36:in `block in call'
warden (1.2.7) lib/warden/manager.rb:35:in `catch'
warden (1.2.7) lib/warden/manager.rb:35:in `call'
rack (2.0.5) lib/rack/tempfile_reaper.rb:15:in `call'
rack (2.0.5) lib/rack/etag.rb:25:in `call'
rack (2.0.5) lib/rack/conditional_get.rb:25:in `call'
rack (2.0.5) lib/rack/head.rb:12:in `call'
actionpack (5.2.1) lib/action_dispatch/http/content_security_policy.rb:18:in `call'
rack (2.0.5) lib/rack/session/abstract/id.rb:232:in `context'
rack (2.0.5) lib/rack/session/abstract/id.rb:226:in `call'
actionpack (5.2.1) lib/action_dispatch/middleware/cookies.rb:670:in `call'
activerecord (5.2.1) lib/active_record/migration.rb:559:in `call'
actionpack (5.2.1) lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'
activesupport (5.2.1) lib/active_support/callbacks.rb:98:in `run_callbacks'
actionpack (5.2.1) lib/action_dispatch/middleware/callbacks.rb:26:in `call'
actionpack (5.2.1) lib/action_dispatch/middleware/executor.rb:14:in `call'
actionpack (5.2.1) lib/action_dispatch/middleware/debug_exceptions.rb:61:in `call'
web-console (3.6.2) lib/web_console/middleware.rb:135:in `call_app'
web-console (3.6.2) lib/web_console/middleware.rb:30:in `block in call'
web-console (3.6.2) lib/web_console/middleware.rb:20:in `catch'
web-console (3.6.2) lib/web_console/middleware.rb:20:in `call'
actionpack (5.2.1) lib/action_dispatch/middleware/show_exceptions.rb:33:in `call'
railties (5.2.1) lib/rails/rack/logger.rb:38:in `call_app'
railties (5.2.1) lib/rails/rack/logger.rb:26:in `block in call'
activesupport (5.2.1) lib/active_support/tagged_logging.rb:71:in `block in tagged'
activesupport (5.2.1) lib/active_support/tagged_logging.rb:28:in `tagged'
activesupport (5.2.1) lib/active_support/tagged_logging.rb:71:in `tagged'
railties (5.2.1) lib/rails/rack/logger.rb:26:in `call'
sprockets-rails (3.2.1) lib/sprockets/rails/quiet_assets.rb:13:in `call'
actionpack (5.2.1) lib/action_dispatch/middleware/remote_ip.rb:81:in `call'
actionpack (5.2.1) lib/action_dispatch/middleware/request_id.rb:27:in `call'
rack (2.0.5) lib/rack/method_override.rb:22:in `call'
rack (2.0.5) lib/rack/runtime.rb:22:in `call'
activesupport (5.2.1) lib/active_support/cache/strategy/local_cache_middleware.rb:29:in `call'
actionpack (5.2.1) lib/action_dispatch/middleware/executor.rb:14:in `call'
actionpack (5.2.1) lib/action_dispatch/middleware/static.rb:127:in `call'
rack (2.0.5) lib/rack/sendfile.rb:111:in `call'
railties (5.2.1) lib/rails/engine.rb:524:in `call'
puma (3.12.0) lib/puma/configuration.rb:225:in `call'
puma (3.12.0) lib/puma/server.rb:658:in `handle_request'
puma (3.12.0) lib/puma/server.rb:472:in `process_client'
puma (3.12.0) lib/puma/server.rb:332:in `block in run'
puma (3.12.0) lib/puma/thread_pool.rb:133:in `block in spawn_thread'

Gemfile:

source 'https://rubygems.org'
gemspec

gem 'rake'

rails = ENV['RAILS'] || '5-0-stable'

if rails == 'master'
  gem 'polyamorous', github: 'activerecord-hackery/polyamorous'
else
  gem 'polyamorous', '~> 1.3'
end

gem 'pry'

# Provide timezone information on Windows
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw]

case rails
when /\// # A path
  gem 'activesupport', path: "#{rails}/activesupport"
  gem 'activerecord', path: "#{rails}/activerecord", require: false
  gem 'actionpack', path: "#{rails}/actionpack"
when /^v/ # A tagged version
  git 'git://github.com/rails/rails.git', :tag => rails do
    gem 'activesupport'
    gem 'activemodel'
    gem 'activerecord', require: false
    gem 'actionpack'
  end
else
  git 'git://github.com/rails/rails.git', :branch => rails do
    gem 'activesupport'
    gem 'activemodel'
    gem 'activerecord', require: false
    gem 'actionpack'
  end
  if rails == '3-0-stable'
    gem 'mysql2', '< 0.3'
  end
  if rails == '5-2-stable'
    gem 'mysql2', '~> 0.4.4'
  end
end

if ENV['DB'] =~ /mongoid4/
  gem 'mongoid', '~> 4.0.0', require: false
end

if ENV['DB'] =~ /mongoid5/
  gem 'mongoid', '~> 5.0.0', require: false
end

group :test do
  # TestUnit was removed from Ruby 2.2 but still needed for testing Rails 3.x.
  gem 'test-unit', '~> 3.0' if RUBY_VERSION >= '2.2'
  gem 'simplecov', :require => false
end
<img width="883" alt="screen shot 2018-08-11 at 9 58 01 am" src="https://user-images.githubusercontent.com/1825103/43992505-1c0f046a-9d4d-11e8-8e2f-f84aafa1b2ab.png">

@LucasCioffi LucasCioffi changed the title ArgumentError (wrong number of arguments (given 4, expected 3)): ArgumentError (wrong number of arguments (given 4, expected 3)) Aug 11, 2018
@jsantos
Copy link

jsantos commented Aug 13, 2018

Guess this is a duplicate of #947

@gregmolnar
Copy link
Member

@LucasCioffi Try to upgrade to ransack 2.0.0, that should fix the problem.

@arbesulo
Copy link

arbesulo commented Aug 1, 2019

This error is happening again in with activerecord-6.0.0.rc2

@gregmolnar
Copy link
Member

@arbesulo Try with ransack master please.

@webzorg
Copy link

webzorg commented Aug 7, 2019

Cannot add github branch as a gem dependency. Could you please release current master as some new version?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants