diff --git a/.github/workflows/codecheck.yml b/.github/workflows/codecheck.yml index 74e9f03..2fb4e6c 100644 --- a/.github/workflows/codecheck.yml +++ b/.github/workflows/codecheck.yml @@ -12,7 +12,9 @@ jobs: steps: - uses: actions/checkout@v2 - uses: ruby/setup-ruby@v1 + env: + BUNDLE_NOKOGIRI___C: "--use-system-libraries" with: ruby-version: 2.7 bundler-cache: true - - run: bundle exec rubocop \ No newline at end of file + - run: bundle exec rubocop diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index bb6a602..d4d18fa 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -12,7 +12,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest] - ruby: [2.5, 2.6, 2.7] + ruby: [2.5, 2.6, 2.7.1] runs-on: ${{ matrix.os }} services: diff --git a/Gemfile b/Gemfile index 6de200c..a21daa0 100644 --- a/Gemfile +++ b/Gemfile @@ -2,7 +2,7 @@ source 'https://rubygems.org' gemspec -gem 'ransack-mongoid', git: 'https://github.com/activerecord-hackery/ransack-mongoid' +gem 'ransack-mongoid', git: 'https://github.com/jesusalc/ransack-mongoid', branch: 'rails-6-mongoid-7-ruby-2-7-0' gem 'rails', '>= 5.2', '< 6.1' diff --git a/Gemfile.lock b/Gemfile.lock index f85a85e..51da8ec 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,8 +1,9 @@ GIT - remote: https://github.com/activerecord-hackery/ransack-mongoid - revision: bd1935293d2f285fa7cf33d2c5c90d981bf67338 + remote: https://github.com/jesusalc/ransack-mongoid + revision: b7f68881081731afdfaa010499d06adc93d17d71 + branch: rails-6-mongoid-7-ruby-2-7-0 specs: - ransack-mongoid (0.1.0) + ransack-mongoid (0.1.1) PATH remote: . diff --git a/lib/active_admin/mongoid/association/relatable.rb b/lib/active_admin/mongoid/association/relatable.rb index 6f17a87..5868c43 100644 --- a/lib/active_admin/mongoid/association/relatable.rb +++ b/lib/active_admin/mongoid/association/relatable.rb @@ -11,4 +11,7 @@ def foreign_key return if embeds? foreign_key.to_sym rescue nil end + + alias_method :association_primary_key, :foreign_key + end diff --git a/lib/active_admin/mongoid/document.rb b/lib/active_admin/mongoid/document.rb index 8f89f92..5ab62c7 100644 --- a/lib/active_admin/mongoid/document.rb +++ b/lib/active_admin/mongoid/document.rb @@ -70,6 +70,14 @@ def associations def reflections *a relations *a end + + def ransackable_scopes_skip_sanitize_args + [] + end + + def self.ransackable_scopes(auth_object = nil) + [] + end end end diff --git a/test_app/app/models/post.rb b/test_app/app/models/post.rb index 57b9704..dfe669d 100644 --- a/test_app/app/models/post.rb +++ b/test_app/app/models/post.rb @@ -10,4 +10,9 @@ class Post embeds_one :author field :'author.city.name' + + def self.ransackable_scopes(auth_object = nil) + [:admin_user] + end + end