Module: Manage::ApplicationHelper
- Defined in:
- app/helpers/manage/application_helper.rb
Instance Method Summary collapse
- #collection_table(collection, resource_class, no_items_text) ⇒ Object
- #condensed_table(resource_class, cols = 2) ⇒ Object
Instance Method Details
#collection_table(collection, resource_class, no_items_text) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'app/helpers/manage/application_helper.rb', line 4 def collection_table collection, resource_class, no_items_text if collection.empty? return content_tag(:h3, resource_class.model_name.human(count: 2)) + content_tag(:p, no_items_text) else rows = [] ths = resource_class.attribute_names.collect do |attr| content_tag(:td, truncate(resource_class.human_attribute_name(attr).to_s, length: 50)) end.join('').html_safe rows << content_tag(:tr, ths) collection.each do |item| tds = resource_class.attribute_names.collect do |attr| content_tag(:td, truncate(item.public_send(attr).to_s, length: 50)) end.join('').html_safe rows << content_tag(:tr, tds) end content_tag(:h3, resource_class.model_name.human(count: 2)) + content_tag(:table, rows.join('').html_safe) end end |
#condensed_table(resource_class, cols = 2) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'app/helpers/manage/application_helper.rb', line 28 def condensed_table resource_class, cols=2 rows = [] resource_class.attribute_names.each_slice(cols).each do |slice| row = slice.collect do |attr| content_tag(:td, resource_class.human_attribute_name(attr)) + content_tag(:td, resource.public_send(attr)) end rows << content_tag(:tr, row.join('').html_safe) end content_tag :table, rows.join('').html_safe end |