Module: SortingTableFor
- Defined in:
- lib/sorting_table_for.rb,
lib/sorting_table_for/i18n.rb,
lib/sorting_table_for/tools.rb,
lib/sorting_table_for/version.rb,
lib/sorting_table_for/format_cell.rb,
lib/sorting_table_for/format_line.rb,
lib/sorting_table_for/model_scope.rb,
lib/sorting_table_for/table_builder.rb
Defined Under Namespace
Modules: I18n, ModelScope, Tools Classes: FormatCell, FormatLine, TableBuilder
Constant Summary collapse
- VERSION =
"0.3.0"
Instance Method Summary collapse
-
#sorting_table_for(object_or_array, *args) ⇒ Object
Method sorting_table_for with builder => SortingTableFor::TableBuilder.
Instance Method Details
#sorting_table_for(object_or_array, *args) ⇒ Object
Method sorting_table_for with builder => SortingTableFor::TableBuilder
# Exemples :
<% sorting_table_for @users do |table| %>
<% end %>
<% sorting_table_for @users do |table| %>
<%= table.caption %>
<%= table.headers %>
<%= table.columns %>
<%= table.footers %>
<% end %>
Options
-
:builder - Set a table builder, default: SortingTableFor::TableBuilder
-
:html - Set html options (id, class, …), default: empty
-
:remote_link - To set actions link with ajax (true or false), default: false
-
:remote_sort - To set link for sorting with ajax (true of false), default: false
-
:i18n - To use or not i18n on values (true or false), default: true
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/sorting_table_for.rb', line 33 def sorting_table_for(object_or_array, *args) raise ArgumentError, 'Missing block' unless block_given? = args. = ([:html]) ? [:html].merge(:class => "#{[:html][:class]} sorting_table_for".strip) : { :class => :sorting_table_for } builder = [:builder] || TableBuilder case object_or_array when Array if object_or_array.last.is_a?(Array) object = object_or_array.last object_or_array.pop else object = object_or_array object_or_array = [] end else object = object_or_array object_or_array = [] end content_tag(:table, ) do yield builder.new(object, object_or_array, self, , params) end end |