Skip to content

Commit 7114d81

Browse files
committed
WIP: admin_user scope not being built
1 parent 5866566 commit 7114d81

File tree

5 files changed

+21
-4
lines changed

5 files changed

+21
-4
lines changed

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ source 'https://rubygems.org'
22

33
gemspec
44

5-
gem 'ransack-mongoid', git: 'https://github.com/activerecord-hackery/ransack-mongoid'
5+
gem 'ransack-mongoid', git: 'https://github.com/jesusalc/ransack-mongoid', branch: 'rails-6-mongoid-7-ruby-2-7-0'
66

77
gem 'rails', '>= 5.2', '< 6.1'
88

Gemfile.lock

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
GIT
2-
remote: https://github.com/activerecord-hackery/ransack-mongoid
3-
revision: bd1935293d2f285fa7cf33d2c5c90d981bf67338
2+
remote: https://github.com/jesusalc/ransack-mongoid
3+
revision: b7f68881081731afdfaa010499d06adc93d17d71
4+
branch: rails-6-mongoid-7-ruby-2-7-0
45
specs:
5-
ransack-mongoid (0.1.0)
6+
ransack-mongoid (0.1.1)
67

78
PATH
89
remote: .

lib/active_admin/mongoid/association/relatable.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,7 @@ def foreign_key
1111
return if embeds?
1212
foreign_key.to_sym rescue nil
1313
end
14+
15+
alias_method :association_primary_key, :foreign_key
16+
1417
end

lib/active_admin/mongoid/document.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,14 @@ def associations
7070
def reflections *a
7171
relations *a
7272
end
73+
74+
def ransackable_scopes_skip_sanitize_args
75+
[]
76+
end
77+
78+
def self.ransackable_scopes(auth_object = nil)
79+
[]
80+
end
7381
end
7482
end
7583

test_app/app/models/post.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,9 @@ class Post
1010

1111
embeds_one :author
1212
field :'author.city.name'
13+
14+
def self.ransackable_scopes(auth_object = nil)
15+
[:admin_user]
16+
end
17+
1318
end

0 commit comments

Comments
 (0)