An array of symbols submitted to
:custom_filter
has a special meaning. The first symbol is sent as a method name to EVERY ActiveRecord object.
If an object responds to this method, the second method name is sent to the returned value unless it is nil, and so on.
The dropdown is populated by the list unique values.
The conditions set up by the user are ignored, that is, the records used are all those found on all pages without any active filters.
Naturally this can be extremely inneffective and should be used with caution.
# encoding: utf-8 class CustomFilters3Controller < ApplicationController def index @tasks_grid = initialize_grid(Task, include: [:relevant_version, :expected_version, :project], conditions: { projects: { id: Project.first.id } }, custom_order: { 'tasks.expected_version_id' => 'expected_versions_tasks.name' } ) end end
<%= grid(@tasks_grid) do |g|
g.column name: 'ID', attribute: 'id', filter: false
g.column name: 'Title', attribute: 'title'
g.column name: 'Found in version', assoc: :relevant_version, attribute: 'name', custom_filter: :auto do |task|
task.relevant_version.name if task.relevant_version
end
g.column name: 'Expected in version', attribute: 'expected_version_id', custom_filter: [:expected_version, :to_option] do |task|
task.expected_version.name if task.expected_version
end
g.column do |task|
link_to('Edit', edit_task_path(task))
end
end -%>
.well %h2= current_page_title %p An array of symbols submitted to %code :custom_filter has a special meaning. The first symbol is sent as a method name to EVERY ActiveRecord object. If an object responds to this method, the second method name is sent to the returned value unless it is nil, and so on. The dropdown is populated by the list unique values. The conditions set up by the user are ignored, that is, the records used are all those found on all pages without any active filters. Naturally this can be extremely inneffective and should be used with caution. = show_code .row-fluid .col-md-12 = render 'grid'
ID | Title | Found in version | Expected in version | |
---|---|---|---|---|
1-20 / 150 Alle rijen tonen | ||||
6 | molestiae autem | 1.2 | Edit | |
7 | ut veniam | 3.0 | Edit | |
9 | quisquam in iste | Edit | ||
13 | ut | 2.0 | Edit | |
14 | repellat consequatur velit | 2.0 | 2.0 | Edit |
20 | aspernatur eligendi adipisci | 3.0 | Edit | |
27 | eum vel | Edit | ||
29 | et | 1.0 | 2.0 | Edit |
31 | debitis pariatur illo | 1.0 | 1.0 | Edit |
32 | voluptatem ipsam libero | 2.0 | 3.0 | Edit |
33 | voluptatem | 1.2 | 1.1 | Edit |
36 | placeat | 2.0 | Edit | |
37 | et | 3.0 | 3.0 | Edit |
42 | aut | 1.2 | Edit | |
44 | id temporibus eligendi | Edit | ||
46 | facere | 3.0 | Edit | |
47 | temporibus iure delectus | Edit | ||
49 | laborum | 3.0 | Edit | |
54 | minima in voluptatem | Edit | ||
59 | alias libero | 3.0 | Edit |