Module: GenericTableHtml::ClassMethods

Included in:
Common::ClassMethods, Generic_Table::ClassMethods
Defined in:
app/models/generic_table_html.rb

Instance Method Summary collapse

Instance Method Details

#column_orderObject

column order for default html generation


13
14
15
16
17
# File 'app/models/generic_table_html.rb', line 13

def column_order
	ret=logical_primary_key
	ret+=column_symbols-logical_primary_key-[:id]
	return ret
end

#header_html(column_order = nil) ⇒ Object

column_order


18
19
20
21
22
23
24
25
26
27
28
# File 'app/models/generic_table_html.rb', line 18

def header_html(column_order=nil)
	if column_order.nil? then
		column_order=self.column_order
	end #if
	ret="<tr>"
	column_order.each do |header|
		ret+='<th>'+header.to_s.humanize+'</th>'
	end #each
	ret+="</tr>"
	return ret
end

#table_html(column_order = nil) ⇒ Object

Produce default HTML for ActiveRecord model


30
31
32
33
34
35
36
37
38
39
40
41
# File 'app/models/generic_table_html.rb', line 30

def table_html(column_order=nil)
	if column_order.nil? then
		column_order=self.column_order
	end #if
	ret="<table>"
	ret+=header_html(column_order)
	self.all.each do |row|
		ret+=row.row_html(column_order)
	end #each
	ret+="</table>"
	return ret
end