Skip to content

Commit 0c79f67

Browse files
committed
Updates for working with mongoid 7.x
1 parent 0947617 commit 0c79f67

7 files changed

Lines changed: 114 additions & 64 deletions

File tree

Gemfile

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

33
gemspec
44

5-
gem 'ransack-mongoid', git: 'https://github.com/activerecord-hackery/ransack-mongoid'
5+
gem 'ransack-mongoid', path: "~/development/open_source/ransack-mongoid/"#, git: 'https://github.com/skalibog/ransack-mongoid'
6+
gem 'ransack', '~> 2.1.0'
67

78
gem 'rails', '>= 5.2', '< 6.1'
9+
gem 'mongoid', '= 7.0.0'
810

911
gem 'devise'
1012

Gemfile.lock

Lines changed: 68 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
GIT
2-
remote: https://github.com/activerecord-hackery/ransack-mongoid
3-
revision: bd1935293d2f285fa7cf33d2c5c90d981bf67338
1+
PATH
2+
remote: ../ransack-mongoid
43
specs:
5-
ransack-mongoid (0.1.0)
4+
ransack-mongoid (0.1.2)
65

76
PATH
87
remote: .
@@ -75,32 +74,34 @@ GEM
7574
activesupport (>= 3.0.0)
7675
ruby2_keywords (>= 0.0.2)
7776
arel (9.0.0)
78-
ast (2.4.0)
79-
bcrypt (3.1.13)
77+
ast (2.4.2)
78+
bcrypt (3.1.20)
8079
bson (5.0.1)
8180
builder (3.3.0)
82-
capybara (3.40.0)
81+
capybara (3.39.2)
8382
addressable
8483
matrix
8584
mini_mime (>= 0.1.3)
86-
nokogiri (~> 1.11)
85+
nokogiri (~> 1.8)
8786
rack (>= 1.6.0)
8887
rack-test (>= 0.6.3)
8988
regexp_parser (>= 1.5, < 3.0)
9089
xpath (~> 3.2)
90+
childprocess (5.1.0)
91+
logger (~> 1.5)
9192
cliver (0.3.2)
92-
coderay (1.1.2)
93+
coderay (1.1.3)
9394
concurrent-ruby (1.3.4)
9495
crass (1.0.6)
9596
date (3.3.4)
96-
devise (4.7.1)
97+
devise (4.9.4)
9798
bcrypt (~> 3.0)
9899
orm_adapter (~> 0.1)
99100
railties (>= 4.1.0)
100101
responders
101102
warden (~> 1.2.3)
102-
diff-lcs (1.3)
103-
docile (1.3.1)
103+
diff-lcs (1.5.1)
104+
docile (1.4.1)
104105
erubi (1.13.0)
105106
ffi (1.17.0)
106107
formtastic (3.1.5)
@@ -119,15 +120,15 @@ GEM
119120
railties (>= 5.2, < 7.1)
120121
responders (>= 2, < 4)
121122
jaro_winkler (1.5.6)
122-
jquery-rails (4.3.3)
123+
jquery-rails (4.6.0)
123124
rails-dom-testing (>= 1, < 3)
124125
railties (>= 4.2.0)
125126
thor (>= 0.14, < 2.0)
126-
jquery-ui-rails (6.0.1)
127+
jquery-ui-rails (7.0.0)
127128
railties (>= 3.2.16)
128129
jslint (1.2.0)
129130
json
130-
json (2.3.1)
131+
json (2.7.2)
131132
kaminari (1.2.2)
132133
activesupport (>= 4.1.0)
133134
kaminari-actionview (= 1.2.2)
@@ -143,8 +144,10 @@ GEM
143144
kaminari-mongoid (1.0.2)
144145
kaminari-core (~> 1.0)
145146
mongoid
146-
launchy (2.4.3)
147-
addressable (~> 2.3)
147+
launchy (3.0.1)
148+
addressable (~> 2.8)
149+
childprocess (~> 5.0)
150+
logger (1.6.0)
148151
loofah (2.22.0)
149152
crass (~> 1.0.2)
150153
nokogiri (>= 1.12.0)
@@ -155,16 +158,15 @@ GEM
155158
net-smtp
156159
marcel (1.0.4)
157160
matrix (0.4.2)
158-
method_source (0.9.2)
161+
method_source (1.1.0)
159162
mini_mime (1.1.5)
160163
mini_portile2 (2.8.7)
161164
minitest (5.24.1)
162165
mongo (2.20.1)
163166
bson (>= 4.14.1, < 6.0.0)
164-
mongoid (7.5.4)
165-
activemodel (>= 5.1, < 7.1, != 7.0.0)
166-
mongo (>= 2.10.5, < 3.0.0)
167-
ruby2_keywords (~> 0.0.5)
167+
mongoid (7.0.0)
168+
activemodel (>= 5.1, < 6.0.0)
169+
mongo (>= 2.5.1, < 3.0.0)
168170
net-imap (0.4.14)
169171
date
170172
net-protocol
@@ -175,25 +177,24 @@ GEM
175177
net-smtp (0.5.0)
176178
net-protocol
177179
nio4r (2.7.3)
178-
nokogiri (1.16.7)
180+
nokogiri (1.15.6)
179181
mini_portile2 (~> 2.8.2)
180182
racc (~> 1.4)
181183
orm_adapter (0.5.0)
182-
parallel (1.19.1)
183-
parser (2.7.0.2)
184-
ast (~> 2.4.0)
184+
parallel (1.26.2)
185+
parser (3.3.4.2)
186+
ast (~> 2.4.1)
187+
racc
185188
poltergeist (1.18.1)
186189
capybara (>= 2.1, < 4)
187190
cliver (~> 0.3.1)
188191
websocket-driver (>= 0.2.0)
189-
polyamorous (2.3.2)
190-
activerecord (>= 5.2.1)
191-
pry (0.12.2)
192-
coderay (~> 1.1.0)
193-
method_source (~> 0.9.0)
194-
pry-rails (0.3.8)
195-
pry (>= 0.10.4)
196-
public_suffix (6.0.1)
192+
pry (0.14.2)
193+
coderay (~> 1.1)
194+
method_source (~> 1.0)
195+
pry-rails (0.3.11)
196+
pry (>= 0.13.0)
197+
public_suffix (5.1.1)
197198
racc (1.8.1)
198199
rack (2.2.9)
199200
rack-test (2.1.0)
@@ -224,35 +225,36 @@ GEM
224225
method_source
225226
rake (>= 0.8.7)
226227
thor (>= 0.19.0, < 2.0)
227-
rainbow (3.0.0)
228+
rainbow (3.1.1)
228229
rake (13.2.1)
229-
ransack (2.3.2)
230-
activerecord (>= 5.2.1)
231-
activesupport (>= 5.2.1)
230+
ransack (2.1.1)
231+
actionpack (>= 5.0)
232+
activerecord (>= 5.0)
233+
activesupport (>= 5.0)
232234
i18n
233-
polyamorous (= 2.3.2)
234235
regexp_parser (2.9.2)
235-
responders (2.4.1)
236-
actionpack (>= 4.2.0, < 6.0)
237-
railties (>= 4.2.0, < 6.0)
238-
rexml (3.2.5)
239-
rspec-core (3.8.0)
240-
rspec-support (~> 3.8.0)
241-
rspec-expectations (3.8.2)
236+
responders (3.1.1)
237+
actionpack (>= 5.2)
238+
railties (>= 5.2)
239+
rexml (3.3.5)
240+
strscan
241+
rspec-core (3.9.3)
242+
rspec-support (~> 3.9.3)
243+
rspec-expectations (3.9.4)
242244
diff-lcs (>= 1.2.0, < 2.0)
243-
rspec-support (~> 3.8.0)
244-
rspec-mocks (3.8.0)
245+
rspec-support (~> 3.9.0)
246+
rspec-mocks (3.9.1)
245247
diff-lcs (>= 1.2.0, < 2.0)
246-
rspec-support (~> 3.8.0)
247-
rspec-rails (3.8.1)
248+
rspec-support (~> 3.9.0)
249+
rspec-rails (3.9.1)
248250
actionpack (>= 3.0)
249251
activesupport (>= 3.0)
250252
railties (>= 3.0)
251-
rspec-core (~> 3.8.0)
252-
rspec-expectations (~> 3.8.0)
253-
rspec-mocks (~> 3.8.0)
254-
rspec-support (~> 3.8.0)
255-
rspec-support (3.8.0)
253+
rspec-core (~> 3.9.0)
254+
rspec-expectations (~> 3.9.0)
255+
rspec-mocks (~> 3.9.0)
256+
rspec-support (~> 3.9.0)
257+
rspec-support (3.9.4)
256258
rubocop (0.80.0)
257259
jaro_winkler (~> 1.5.1)
258260
parallel (~> 1.10)
@@ -261,7 +263,7 @@ GEM
261263
rexml
262264
ruby-progressbar (~> 1.7)
263265
unicode-display_width (>= 1.4.0, < 1.7)
264-
ruby-progressbar (1.10.1)
266+
ruby-progressbar (1.13.0)
265267
ruby2_keywords (0.0.5)
266268
sass-rails (6.0.0)
267269
sassc-rails (~> 2.1, >= 2.1.1)
@@ -273,27 +275,29 @@ GEM
273275
sprockets (> 3.0)
274276
sprockets-rails
275277
tilt
276-
simplecov (0.16.1)
278+
simplecov (0.22.0)
277279
docile (~> 1.1)
278-
json (>= 1.8, < 3)
279-
simplecov-html (~> 0.10.0)
280-
simplecov-html (0.10.2)
280+
simplecov-html (~> 0.11)
281+
simplecov_json_formatter (~> 0.1)
282+
simplecov-html (0.12.3)
283+
simplecov_json_formatter (0.1.4)
281284
sprockets (4.0.3)
282285
concurrent-ruby (~> 1.0)
283286
rack (> 1, < 3)
284287
sprockets-rails (3.4.2)
285288
actionpack (>= 5.2)
286289
activesupport (>= 5.2)
287290
sprockets (>= 3.0.0)
291+
strscan (3.1.0)
288292
thor (1.3.1)
289293
thread_safe (0.3.6)
290294
tilt (2.4.0)
291295
timeout (0.4.1)
292296
tzinfo (1.2.11)
293297
thread_safe (~> 0.1)
294298
unicode-display_width (1.6.1)
295-
warden (1.2.8)
296-
rack (>= 2.0.6)
299+
warden (1.2.9)
300+
rack (>= 2.0.9)
297301
websocket-driver (0.7.6)
298302
websocket-extensions (>= 0.1.0)
299303
websocket-extensions (0.1.5)
@@ -311,9 +315,11 @@ DEPENDENCIES
311315
jquery-ui-rails
312316
jslint
313317
launchy
318+
mongoid (= 7.0.0)
314319
poltergeist
315320
pry-rails
316321
rails (>= 5.2, < 6.1)
322+
ransack (~> 2.1.0)
317323
ransack-mongoid!
318324
rspec-rails (~> 3.6)
319325
rubocop (= 0.80.0)

docker-compose.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
version: '3'
2+
services:
3+
db:
4+
image: mongo:6
5+
restart: unless-stopped
6+
volumes:
7+
- mongo5fission:/data/db
8+
ports:
9+
- "127.0.0.1:27017:27017"
10+
volumes:
11+
mongofission:
12+
mongo5fission:
13+
esdata:

lib/active_admin/mongoid.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
require 'active_admin/mongoid/association/relatable'
1717

1818
require 'active_admin/mongoid/inputs/filters/check_boxes_input'
19+
require 'active_admin/mongoid/inputs/filters/select_input'
1920
require 'active_admin/mongoid/filters/active_filter'
2021
require 'active_admin/mongoid/filters/resource_extension'
2122
require 'active_admin/mongoid/controllers/resource_controller'
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
require 'active_admin/inputs/filters/select_input'
2+
3+
class ActiveAdmin::Inputs::Filters::SelectInput
4+
def searchable_method_name
5+
if searchable_has_many_through?
6+
"#{reflection.through_reflection.name}_#{reflection.foreign_key}"
7+
else
8+
reflection&.key || method
9+
end
10+
rescue => e
11+
binding.pry
12+
end
13+
14+
def input_name
15+
return method if seems_searchable?
16+
17+
searchable_method_name&.to_s + (multiple? ? '_in' : '_eq')
18+
end
19+
end

test_app/app/models/post.rb

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

1111
embeds_one :author
1212
field :'author.city.name'
13+
14+
def self.ransack(*args)
15+
16+
binding.pry unless args.first.empty?
17+
18+
super
19+
20+
end
21+
1322
end

test_app/config/mongoid.6.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ test:
33
default:
44
database: activeadmin_mongoid_test
55
hosts:
6-
- localhost:27017
6+
- db:27017
77
#scope_overwrite_exception: true

0 commit comments

Comments
 (0)