Module: Spectabular::Helper

Defined in:
lib/spectabular/helper.rb

Instance Method Summary collapse

Instance Method Details

#table_for(collection, *columns) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/spectabular/helper.rb', line 4

def table_for(collection,*columns)
  columns = columns.first if columns.size <= 1
  columns ||= default_columns_for(collection)
  @table = Spectabular::Table.new(  :collection => instance_variable_get("@#{collection}"),
                                    :collection_name => collection.to_s.humanize,
                                    :columns => columns,
                                    :context => self
                                    )
  output = []
  if @table.empty?
    output << @table.empty_message.html_safe
  else
    output << (:table, join_formatted([spectabular_header,spectabular_body]), :class => "spectabular").html_safe
    output << spectabular_pagination.html_safe
  end
  join_formatted output
end