Class: Views::Resources::Index

Inherits:
Base
  • Object
show all
Defined in:
app/views/resources/index.rb

Instance Method Summary collapse

Instance Method Details

#blank_slateObject



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_contentObject



10
11
12
13
# File 'app/views/resources/index.rb', line 10

def body_content
  page_header
  item_list
end

#item_listObject



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


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_headerObject



2
3
4
# File 'app/views/resources/index.rb', line 2

def page_header
  h1 "#{resource_name} Index"
end