File tree Expand file tree Collapse file tree 4 files changed +18
-17
lines changed
Expand file tree Collapse file tree 4 files changed +18
-17
lines changed Original file line number Diff line number Diff line change @@ -3,12 +3,14 @@ class Avo::Resources::Cloud < Avo::BaseResource
33
44 self . search = {
55 query : -> {
6- query . ransack (
7- participant_full_name_cont : params [ :q ] ,
8- participant_email_cont : params [ :q ] ,
9- m : "or"
10- ) . result ( distinct : false )
11- }
6+ query . joins ( :participant )
7+ . merge ( Participant . search ( params [ :q ] ) )
8+ } ,
9+ item : -> do
10+ {
11+ title : "#{ record . id } (#{ record . participant . full_name } — #{ record . participant . email } )"
12+ }
13+ end
1214 }
1315
1416 class BulkDelete < Avo ::BaseAction
Original file line number Diff line number Diff line change @@ -3,12 +3,14 @@ class Avo::Resources::Invitation < Avo::BaseResource
33
44 self . search = {
55 query : -> {
6- query . ransack (
7- participant_full_name_cont : params [ :q ] ,
8- participant_email_cont : params [ :q ] ,
9- m : "or"
10- ) . result ( distinct : false )
11- }
6+ query . joins ( :participant )
7+ . merge ( Participant . search ( params [ :q ] ) )
8+ } ,
9+ item : -> do
10+ {
11+ title : "#{ record . id } (#{ record . participant . full_name } — #{ record . participant . email } )"
12+ }
13+ end
1214 }
1315
1416 def fields
Original file line number Diff line number Diff line change @@ -4,11 +4,7 @@ class Avo::Resources::Participant < Avo::BaseResource
44
55 self . search = {
66 query : -> {
7- query . ransack (
8- full_name_cont : params [ :q ] ,
9- email_cont : params [ :q ] ,
10- m : "or"
11- ) . result ( distinct : false )
7+ query . merge ( Participant . search ( params [ :q ] ) )
128 }
139 }
1410
Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ class Participant < ApplicationRecord
1515
1616 scope :without_picked_cloud , -> { where . missing ( :picked_cloud ) }
1717 scope :without_invitations , -> { where . missing ( :invitations ) }
18+ scope :search , -> ( q ) { where ( arel_table [ :full_name ] . matches ( "%#{ q } %" ) . or ( arel_table [ :email ] . matches ( "%#{ q } %" ) ) ) }
1819
1920 before_create do
2021 self . access_token ||= Nanoid . generate ( size : 6 )
You can’t perform that action at this time.
0 commit comments