Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
open-source
aoz-003
Commits
ac8a7c62
Verified
Commit
ac8a7c62
authored
Jan 31, 2018
by
Kaspar Vollenweider
👻
Browse files
default filter q params through controller method
parent
cfb130e5
Changes
1
Hide whitespace changes
Inline
Side-by-side
app/controllers/clients_controller.rb
View file @
ac8a7c62
...
...
@@ -8,7 +8,7 @@ class ClientsController < ApplicationController
def
index
authorize
Client
@q
=
policy_scope
(
Client
).
ransack
(
params
[
:q
]
)
@q
=
policy_scope
(
Client
).
ransack
(
default_filter
)
@q
.
sorts
=
[
'created_at desc'
]
if
@q
.
sorts
.
empty?
@clients
=
@q
.
result
respond_to
do
|
format
|
...
...
@@ -80,6 +80,15 @@ class ClientsController < ApplicationController
private
def
default_filter
return
{
acceptance_not_eq:
2
}
if
params
[
:q
].
blank?
filters
=
params
.
to_unsafe_hash
[
:q
]
if
filters
[
:acceptance_eq
].
present?
||
filters
[
:contact_full_name_cont
].
present?
filters
.
except
(
:acceptance_not_eq
)
else
filters
.
merge
(
acceptance_not_eq:
2
)
end
end
end
def
set_client
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment