Create implemented Company

- Create route and view implemented with minimal info
- index implemented and shows number of registered companies
This commit is contained in:
Okechi Onyeje 2017-01-20 02:40:43 -05:00
parent ace1290a76
commit 7c6cf0f38d
4 changed files with 60 additions and 40 deletions

View File

@ -1,4 +1,4 @@
class Company < ApplicationRecord class Company < ApplicationRecord
belongs_to :user has_many :users
has_many :runs has_many :runs
end end

View File

@ -1,5 +1,5 @@
class User < ApplicationRecord class User < ApplicationRecord
has_one :company belongs_to :company
has_many :runs has_many :runs
# Include default devise modules. Others available are: # Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable # :confirmable, :lockable, :timeoutable and :omniauthable

View File

@ -59,15 +59,14 @@
</div> </div>
<div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main"> <div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
<h1 class="page-header">Companies</h1> <h1 class="page-header">Companies</h1>
<h2 class="sub-header">Registered Companies</h2> <h2 class="sub-header">Registered Companies: <%= @companies.count %> </h2>
<div class="table-responsive"> <div class="panel panel-primary table-responsive">
<%= link_to(new_company_path, :method => :get) do %> <%= link_to(new_company_path, :method => :get) do %>
<i class="fa fa-external-link"></i> Register a Company <i class="fa fa-external-link"></i> Register a Company
<% end %> <% end %>
<table class="table table-striped"> <table class="table table-striped">
<thead> <thead>
<tr> <tr>
<th>#</th>
<th>Company ID</th> <th>Company ID</th>
<th>Company Name</th> <th>Company Name</th>
<th>Registration Serial Key</th> <th>Registration Serial Key</th>
@ -80,6 +79,27 @@
</div> </div>
<% else %> <% else %>
<tbody> <tbody>
<% @companies.each_slice(1) do |row| %>
<tr>
<% row.each do |company|%>
<!-- company id -->
<td>
<%= company.id %>
</td>
<!-- company_name -->
<td>
<%= company.company_name %>
</td>
<!-- company registration token -->
<td>
<%= company.company_token %>
</td>
<% end %>
</tr>
<% end %>
</tbody> </tbody>
</table> </table>
<% end %> <% end %>