Created
September 14, 2018 09:48
-
-
Save tonyfg/8a877ecc9b6645fb326445e4a361f764 to your computer and use it in GitHub Desktop.
Org list HTML views
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# app/views/organizations/index.html.erb | |
<table> | |
<tbody> | |
<% @organizations.each do |organization| %> | |
<tr> | |
<td><%= organization.name % ></td> | |
<td><%= organization.address %></td> | |
<td><%= organization.contact_name %></td> | |
<td><%= organization.contact_phone %></td> | |
<td><%= render 'hq_list', organization: organization %></td> | |
<td><%= link_to 'Show', organization %></td> | |
<td><%= link_to 'Edit', edit_organization_path(organization) %></td> | |
<td><%= link_to 'Destroy', organization, method: :delete, data: { confirm: 'Are you sure?' } %></td> | |
</tr> | |
<% end %> | |
</tbody> | |
</table> | |
# app/views/organizations/_hq_list.html.erb | |
<% organization.hqs.each do |hq| %> | |
<%= hq.name %>: <%= hq.country.name %> (<%= hq.stores.count %> stores) <br> | |
<% end %> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment