-
Notifications
You must be signed in to change notification settings - Fork 37
/
Copy patheffective_datatables.rb
59 lines (49 loc) · 2.39 KB
/
effective_datatables.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
EffectiveDatatables.setup do |config|
# Authorization Method
#
# This method is called by all controller actions with the appropriate action and resource
# If it raises an exception or returns false, an Effective::AccessDenied Error will be raised
#
# Use via Proc:
# Proc.new { |controller, action, resource| authorize!(action, resource) } # CanCan
# Proc.new { |controller, action, resource| can?(action, resource) } # CanCan with skip_authorization_check
# Proc.new { |controller, action, resource| authorize "#{action}?", resource } # Pundit
# Proc.new { |controller, action, resource| current_user.is?(:admin) } # Custom logic
#
# Use via Boolean:
# config.authorization_method = true # Always authorized
# config.authorization_method = false # Always unauthorized
#
# Use via Method (probably in your application_controller.rb):
# config.authorization_method = :my_authorization_method
# def my_authorization_method(resource, action)
# true
# end
config.authorization_method = Proc.new { |controller, action, resource| authorize!(action, resource) }
# Display x per page options
config.length_menu = [5, 10, 25, 50, 100, 250, 500]
# Default number of entries shown per page. Must be in the length_menu.
config.default_length = 25
# Default class used on the <table> tag
config.html_class = 'table table-hover'
# Log search/sort information to the console
config.debug = true
# Use a cookie to save and restore state from previous page visits.
config.save_state = true
# Configure the _effective_dt cookie.
config.cookie_max_size = 1500 # String size. Final byte size is about 1.5 times bigger, after rails signs it
config.cookie_domain = :all # Should usually be :all
config.cookie_tld_length = nil # Leave nil to autodetect, or set to probably 2
# Date formatting
config.format_datetime = '%F %H:%M'
config.format_date = '%F'
config.format_time = '%H:%M'
# Boolean formatting. When present will render booleans as badges with this bootstrap color
config.format_true = 'success'
config.format_false = 'danger'
# Enable the Download button which serves a CSV of your collection
config.download = false
# Call jit_preloader on ActiveRecord collections automatically. Must have jit_preloader gem installed.
# https://github.com/clio/jit_preloader
config.use_jit_preloader = false
end