From 7c6cf0f38d9fe39dffb3675758523c6e8d4ec0f9 Mon Sep 17 00:00:00 2001 From: Okechi Onyeje Date: Fri, 20 Jan 2017 02:40:43 -0500 Subject: [PATCH] Create implemented Company - Create route and view implemented with minimal info - index implemented and shows number of registered companies --- Pearlception/app/models/company.rb | 2 +- Pearlception/app/models/user.rb | 2 +- .../app/views/companies/index.html.erb | 26 ++++++- .../app/views/dashboard/index.html.erb | 70 +++++++++---------- 4 files changed, 60 insertions(+), 40 deletions(-) diff --git a/Pearlception/app/models/company.rb b/Pearlception/app/models/company.rb index 3a4fb41..fdc526f 100644 --- a/Pearlception/app/models/company.rb +++ b/Pearlception/app/models/company.rb @@ -1,4 +1,4 @@ class Company < ApplicationRecord - belongs_to :user + has_many :users has_many :runs end diff --git a/Pearlception/app/models/user.rb b/Pearlception/app/models/user.rb index 0a39c7f..a44f648 100644 --- a/Pearlception/app/models/user.rb +++ b/Pearlception/app/models/user.rb @@ -1,5 +1,5 @@ class User < ApplicationRecord - has_one :company + belongs_to :company has_many :runs # Include default devise modules. Others available are: # :confirmable, :lockable, :timeoutable and :omniauthable diff --git a/Pearlception/app/views/companies/index.html.erb b/Pearlception/app/views/companies/index.html.erb index 8a195dd..b505cdf 100644 --- a/Pearlception/app/views/companies/index.html.erb +++ b/Pearlception/app/views/companies/index.html.erb @@ -59,15 +59,14 @@

Companies

-

Registered Companies

-
+

Registered Companies: <%= @companies.count %>

+
<%= link_to(new_company_path, :method => :get) do %> Register a Company <% end %> - @@ -80,6 +79,27 @@ <% else %> + <% @companies.each_slice(1) do |row| %> + + <% row.each do |company|%> + + + + + + + + + + <% end %> + + <% end %>
# Company ID Company Name Registration Serial Key
+ <%= company.id %> + + <%= company.company_name %> + + <%= company.company_token %> +
<% end %> diff --git a/Pearlception/app/views/dashboard/index.html.erb b/Pearlception/app/views/dashboard/index.html.erb index 6d231d2..accc7ef 100644 --- a/Pearlception/app/views/dashboard/index.html.erb +++ b/Pearlception/app/views/dashboard/index.html.erb @@ -159,48 +159,48 @@ <% end %> <% else %> - <% @results.each_slice(1) do |row| %> - - <% row.each do |result| - run = Run.find(result.id) %> - - - <%= run.runDate %> - + <% @results.each_slice(1) do |row| %> + + <% row.each do |result| + run = Run.find(result.id) %> + + + <%= run.runDate %> + - - - <%= run.location ? run.location : "" %> - + + + <%= run.location ? run.location : "" %> + - - - <%= "" %> - + + + <%= "" %> + - - + + - <%= run.supplier ? run.supplier : "" %> - + <%= run.supplier ? run.supplier : "" %> + - - - <%= run.distributor ? run.distributor : "" %> - + + + <%= run.distributor ? run.distributor : "" %> + - - - <%= result.total %> - + + + <%= result.total %> + - - - <%= run.other ? run.other : "" %> - - <% end %> - - <% end %> + + + <%= run.other ? run.other : "" %> + + <% end %> + + <% end %> <% end %>