Class: Views::Resources::Index
- Inherits:
-
Base
- Object
- Base
- Views::Resources::Index
- Defined in:
- app/views/resources/index.rb
Instance Method Summary collapse
- #blank_slate ⇒ Object
- #body_content ⇒ Object
- #item_list ⇒ Object
- #links_for_item(item) ⇒ Object
- #list_representation(item) ⇒ Object
- #page_header ⇒ Object
Instance Method Details
#blank_slate ⇒ Object
6 7 8 |
# File 'app/views/resources/index.rb', line 6 def blank_slate link_to "Create a #{resource_name}", new_resource_path end |
#body_content ⇒ Object
10 11 12 13 |
# File 'app/views/resources/index.rb', line 10 def body_content page_header item_list end |
#item_list ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'app/views/resources/index.rb', line 15 def item_list blank_slate if collection.any? ul do collection.each do |item| li do links_for_item(item) end end end end end |
#links_for_item(item) ⇒ Object
28 29 30 |
# File 'app/views/resources/index.rb', line 28 def links_for_item(item) link_to list_representation(item), resource_path(item) end |
#list_representation(item) ⇒ Object
32 33 34 35 36 37 38 39 40 |
# File 'app/views/resources/index.rb', line 32 def list_representation(item) if item.respond_to?(:name) item.name elsif item.respond_to?(:title) item.title else item.to_s end end |
#page_header ⇒ Object
2 3 4 |
# File 'app/views/resources/index.rb', line 2 def page_header h1 "#{resource_name} Index" end |