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

Ransack doesn't work with rails 6.1.0.rc1 #1163

Closed
itsalongstory opened this issue Nov 20, 2020 · 3 comments · Fixed by #1172
Closed

Ransack doesn't work with rails 6.1.0.rc1 #1163

itsalongstory opened this issue Nov 20, 2020 · 3 comments · Fixed by #1172

Comments

@itsalongstory
Copy link
Contributor

ransack_rails6.1.0.rc1.rb

require 'bundler/inline'

gemfile(true) do
  source 'https://rubygems.org'
  gem 'activerecord', '~> 6.1.0.rc1', require: "active_record"
  gem 'sqlite3', '~> 1.4'
  gem 'ransack', '~> 2.3', '>= 2.3.2'
  gem 'minitest', '~> 5.14', '>= 5.14.2', require: "minitest/autorun"
end

ActiveRecord::Base.establish_connection(
  adapter:  "sqlite3",
  database: "./test_ransack_bug"
)

ActiveRecord::Schema.define do
  drop_table(:users, if_exists: true)
  drop_table(:topics, if_exists: true)

  create_table :users do |t|
    t.string :name
  end

  create_table :topics do |t|
    t.string :title
    t.belongs_to :users, null: false, foreign_key: true
  end
end

class User < ActiveRecord::Base
  has_many :topics
end

class Topic < ActiveRecord::Base
  belongs_to :user
end

class MyTest < Minitest::Test
  def test_should_be_true
    assert_equal Topic.joins(:user).to_sql, "SELECT \"topics\".* FROM \"topics\" INNER JOIN \"users\" ON \"users\".\"id\" = \"topics\".\"user_id\""
  end
end
deploy@ip-172-26-2-105:~$ ruby ransack_rails6.1.0.rc1.rb
Fetching gem metadata from https://rubygems.org/........
Resolving dependencies...
Using concurrent-ruby 1.1.7
Using i18n 1.8.5
Using minitest 5.14.2
Using tzinfo 2.0.3
Using zeitwerk 2.4.1
Using activesupport 6.1.0.rc1
Using activemodel 6.1.0.rc1
Using activerecord 6.1.0.rc1
Using bundler 2.1.4
Using polyamorous 2.3.2
Using ransack 2.3.2
Using sqlite3 1.4.2
-- drop_table(:users, {:if_exists=>true})
   -> 0.1068s
-- drop_table(:topics, {:if_exists=>true})
   -> 0.0053s
-- create_table(:users)
   -> 0.0049s
-- create_table(:topics)
   -> 0.0086s
Run options: --seed 13064

# Running:

E

Finished in 0.004383s, 228.1556 runs/s, 0.0000 assertions/s.

  1) Error:
MyTest#test_should_be_true:
ArgumentError: wrong number of arguments (given 3, expected 2)
    /home/deploy/.rvm/gems/ruby-2.6.5/gems/polyamorous-2.3.2/lib/polyamorous/activerecord_6.0_ruby_2/join_dependency.rb:32:in `join_constraints'
    /home/deploy/.rvm/gems/ruby-2.6.5/gems/activerecord-6.1.0.rc1/lib/active_record/relation/query_methods.rb:1272:in `build_joins'
    /home/deploy/.rvm/gems/ruby-2.6.5/gems/activerecord-6.1.0.rc1/lib/active_record/relation/query_methods.rb:1136:in `build_arel'
    /home/deploy/.rvm/gems/ruby-2.6.5/gems/activerecord-6.1.0.rc1/lib/active_record/relation/query_methods.rb:1059:in `arel'
    /home/deploy/.rvm/gems/ruby-2.6.5/gems/activerecord-6.1.0.rc1/lib/active_record/relation.rb:672:in `block in to_sql'
    /home/deploy/.rvm/gems/ruby-2.6.5/gems/activerecord-6.1.0.rc1/lib/active_record/connection_adapters/abstract_adapter.rb:245:in `unprepared_statement'
    /home/deploy/.rvm/gems/ruby-2.6.5/gems/activerecord-6.1.0.rc1/lib/active_record/relation.rb:672:in `to_sql'
    ransack_rails6.1.0.rc1.rb:40:in `test_should_be_true'

1 runs, 0 assertions, 0 failures, 1 errors, 0 skips
@deivid-rodriguez
Copy link
Contributor

Can you try #1163 against your apps and let me know how it works?

@itsalongstory
Copy link
Contributor Author

gem 'ransack', github: 'activerecord-hackery/ransack', branch: 'rails_6.1_support' fixed this issue, thanks @deivid-rodriguez

@n-rodriguez
Copy link

awesome! thank you @deivid-rodriguez !

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

Successfully merging a pull request may close this issue.

3 participants