Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

rebuilding index and show views for both contact types

  • Loading branch information...
commit 2765b454979e18933db5c0eeced83e5a829f526e 1 parent ecc7419
@jcasimir jcasimir authored
View
28 app/views/companies/index.html.erb
@@ -1,21 +1,13 @@
<% title "Companies" %>
-<table>
- <tr>
- <th>Name</th>
- <th>Email Addresses</th>
- <th>Phone Numbers</th>
- </tr>
- <% for company in @companies %>
- <tr>
- <td><%= company.name %></td>
- <td><%= render :partial => 'email_addresses', :object => company.email_addresses %>
- <td><%= render :partial => 'phone_numbers', :object => company.phone_numbers %>
- <td><%= link_to "Show", company %></td>
- <td><%= link_to "Edit", edit_company_path(company) %></td>
- <td><%= link_to "Destroy", company, :confirm => 'Are you sure?', :method => :delete %></td>
- </tr>
- <% end %>
-</table>
-
<p><%= link_to "New Company", new_company_path %></p>
+
+<div class="companies">
+ <% @companies.each do |company| %>
+ <div class="company">
+ <h4><%= link_to company.name, company %></h4>
+ <%= render :partial => "phone_numbers/list", :object => company.phone_numbers %>
+ <%= render :partial => "email_addresses/list", :object => company.email_addresses %>
+ </div>
+ <% end %>
+</div>
View
29 app/views/companies/show.html.erb
@@ -1,26 +1,13 @@
-<% title "Company" %>
-
-<p>
- <strong>Name:</strong>
- <%= @company.name %>
-</p>
-
-<p>
- <strong>Phone Numbers:</strong>
- <%= render :partial => 'phone_numbers', :object => @company.phone_numbers %>
-</p>
+<% title @company.name %>
+<%= render :partial => 'phone_numbers', :object => @company.phone_numbers %>
<%= link_to "Add a New Phone Number", new_phone_number_path(:company_id => @company), :id => "new_phone_number" %>
-<p>
- <strong>Email Addresses:</strong>
- <%= render :partial => 'email_addresses', :object => @company.email_addresses %>
-</p>
-
+<%= render :partial => 'email_addresses', :object => @company.email_addresses %>
<%= link_to "Add a New Email Address", new_email_address_path(:company_id => @company), :id => "new_email_address" %>
-<p>
- <%= link_to "Edit", edit_company_path(@company) %> |
- <%= link_to "Destroy", @company, :confirm => 'Are you sure?', :method => :delete %> |
- <%= link_to "View All", companies_path %>
-</p>
+<ul class='actions'>
+ <li><%= link_to "Edit", edit_company_path(@company) %></li>
+ <li><%= link_to "Destroy", @company, :confirm => 'Are you sure?', :method => :delete %></li>
+ <li><%= link_to "View All", companies_path %></li>
+</ul>
View
9 app/views/email_addresses/_list.html.erb
@@ -0,0 +1,9 @@
+<ul class='email_addresses'>
+ <% list.each do |email_address| %>
+ <li>
+ <%= email_address.address%>
+ <%= link_to "edit", edit_email_address_path(email_address) %>
+ <%= link_to "delete", email_address_path(email_address), :method => :delete, :id => "delete_email_address_#{email_address.id}" %>
+ </li>
+ <% end %>
+</ul>
View
30 app/views/people/index.html.erb
@@ -1,23 +1,13 @@
<% title "People" %>
-<table>
- <tr>
- <th>First Name</th>
- <th>Last Name</th>
- <th>Phone Numbers</th>
- <th>Email Addresses</th>
- </tr>
- <% for person in @people %>
- <tr>
- <td><%= person.first_name %></td>
- <td><%= person.last_name %></td>
- <td><%= render :partial => 'phone_numbers', :object => person.phone_numbers %></td>
- <td><%= render :partial => 'email_addresses', :object => person.email_addresses %>
- <td><%= link_to "Show", person %></td>
- <td><%= link_to "Edit", edit_person_path(person) %></td>
- <td><%= link_to "Destroy", person, :confirm => 'Are you sure?', :method => :delete %></td>
- </tr>
- <% end %>
-</table>
-
<p><%= link_to "New Person", new_person_path %></p>
+
+<div class="companies">
+ <% @people.each do |person| %>
+ <div class="person">
+ <h4><%= link_to "#{person.last_name}, #{person.first_name}", person %></h4>
+ <%= render :partial => "phone_numbers/list", :object => person.phone_numbers %>
+ <%= render :partial => "email_addresses/list", :object => person.email_addresses %>
+ </div>
+ <% end %>
+</div>
View
32 app/views/people/show.html.erb
@@ -1,29 +1,13 @@
-<% title "Person" %>
-
-<p>
- <strong>First Name:</strong>
- <%= @person.first_name %>
-</p>
-<p>
- <strong>Last Name:</strong>
- <%= @person.last_name %>
-</p>
-<p>
- <strong>Phone Numbers:</strong>
- <%= render :partial => 'phone_numbers', :object => @person.phone_numbers %>
-</p>
+<% title "#{@person.last_name}, #{@person.first_name}" %>
+<%= render :partial => 'phone_numbers', :object => @person.phone_numbers %>
<%= link_to "Add a New Phone Number", new_phone_number_path(:person_id => @person.id ) %>
-<p>
- <strong>Email Addresses:</strong>
- <%= render :partial => 'email_addresses', :object => @person.email_addresses %>
-</p>
-
+<%= render :partial => 'email_addresses', :object => @person.email_addresses %>
<%= link_to "Add a New Email Address", new_email_address_path(:person_id => @person.id ), :id => "new_email_address" %>
-<p>
- <%= link_to "Edit", edit_person_path(@person) %> |
- <%= link_to "Destroy", @person, :confirm => 'Are you sure?', :method => :delete %> |
- <%= link_to "View All", people_path %>
-</p>
+<ul class='actions'>
+ <li><%= link_to "Edit", edit_person_path(@person) %></li>
+ <li><%= link_to "Destroy", @person, :confirm => 'Are you sure?', :method => :delete %></li>
+ <li><%= link_to "View All", people_path %></li>
+</ul>
View
9 app/views/phone_numbers/_list.html.erb
@@ -0,0 +1,9 @@
+<ul class='phone_numbers'>
+ <% list.each do |phone_number| %>
+ <li>
+ <%= phone_number.number%>
+ <%= link_to "edit", edit_phone_number_path(phone_number) %>
+ <%= link_to "delete", phone_number_path(phone_number), :method => :delete, :id => "delete_phone_number_#{phone_number.id}" %>
+ </li>
+ <% end %>
+</ul>
Please sign in to comment.
Something went wrong with that request. Please try again.