diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 00000000..fadd49af Binary files /dev/null and b/.DS_Store differ diff --git a/Gemfile b/Gemfile index e87fad5f..8494f595 100644 --- a/Gemfile +++ b/Gemfile @@ -3,8 +3,7 @@ source 'https://rubygems.org' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' gem 'rails', '4.2.7' -# Use sqlite3 as the database for Active Record -gem 'sqlite3' + # Use SCSS for stylesheets gem 'sass-rails', '~> 5.0' # Use Uglifier as compressor for JavaScript assets @@ -35,6 +34,8 @@ gem 'sdoc', '~> 0.4.0', group: :doc group :development, :test do # Call 'byebug' anywhere in the code to stop execution and get a debugger console gem 'byebug' + # Use sqlite3 as the database for Active Record + gem 'sqlite3' end group :development do @@ -45,3 +46,7 @@ group :development do gem 'spring' end +group :production do + gem 'pg' + gem 'rails_12factor' +end diff --git a/Gemfile.lock b/Gemfile.lock index 6c97c19f..e3e361b4 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -76,6 +76,7 @@ GEM nokogiri (1.6.8) mini_portile2 (~> 2.1.0) pkg-config (~> 1.1.7) + pg (0.19.0) pkg-config (1.1.7) rack (1.6.4) rack-test (0.6.3) @@ -99,6 +100,11 @@ GEM rails-deprecated_sanitizer (>= 1.0.1) rails-html-sanitizer (1.0.3) loofah (~> 2.0) + rails_12factor (0.0.3) + rails_serve_static_assets + rails_stdout_logging + rails_serve_static_assets (0.0.5) + rails_stdout_logging (0.0.5) railties (4.2.7) actionpack (= 4.2.7) activesupport (= 4.2.7) @@ -151,7 +157,9 @@ DEPENDENCIES coffee-rails (~> 4.1.0) jbuilder (~> 2.0) jquery-rails + pg rails (= 4.2.7) + rails_12factor sass-rails (~> 5.0) sdoc (~> 0.4.0) spring diff --git a/app/.DS_Store b/app/.DS_Store new file mode 100644 index 00000000..b1504a01 Binary files /dev/null and b/app/.DS_Store differ diff --git a/app/assets/images/fruits.jpg b/app/assets/images/fruits.jpg new file mode 100644 index 00000000..1e0f7cee Binary files /dev/null and b/app/assets/images/fruits.jpg differ diff --git a/app/assets/images/healthy-organic-food.jpg b/app/assets/images/healthy-organic-food.jpg new file mode 100644 index 00000000..3124bbf2 Binary files /dev/null and b/app/assets/images/healthy-organic-food.jpg differ diff --git a/app/assets/images/lemons.jpg b/app/assets/images/lemons.jpg new file mode 100644 index 00000000..3288390d Binary files /dev/null and b/app/assets/images/lemons.jpg differ diff --git a/app/assets/images/tomatoes.jpg b/app/assets/images/tomatoes.jpg new file mode 100644 index 00000000..83deaf55 Binary files /dev/null and b/app/assets/images/tomatoes.jpg differ diff --git a/app/assets/images/vege.jpeg b/app/assets/images/vege.jpeg new file mode 100644 index 00000000..d34ca264 Binary files /dev/null and b/app/assets/images/vege.jpeg differ diff --git a/app/assets/javascripts/markets.coffee b/app/assets/javascripts/markets.coffee new file mode 100644 index 00000000..24f83d18 --- /dev/null +++ b/app/assets/javascripts/markets.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/app/assets/javascripts/products.coffee b/app/assets/javascripts/products.coffee new file mode 100644 index 00000000..24f83d18 --- /dev/null +++ b/app/assets/javascripts/products.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/app/assets/javascripts/sales.coffee b/app/assets/javascripts/sales.coffee new file mode 100644 index 00000000..24f83d18 --- /dev/null +++ b/app/assets/javascripts/sales.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/app/assets/javascripts/vendors.coffee b/app/assets/javascripts/vendors.coffee new file mode 100644 index 00000000..24f83d18 --- /dev/null +++ b/app/assets/javascripts/vendors.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css index f9cd5b34..32b264ef 100644 --- a/app/assets/stylesheets/application.css +++ b/app/assets/stylesheets/application.css @@ -1,3 +1,124 @@ +/*Section A: Overall font, background image, header, footer, body's background container */ + +* { + font-family: 'Lora', serif; +} + +body { + background-image: url("healthy-organic-food.jpg"); + background-size: auto; +} + +.container { + margin: 30px 30px 30px 30px; + padding: 3px 50px 5px 50px; + background-color: #F1F2F2; + opacity: 0.90; + border-radius: 20px; +} + +header { + border-bottom: 5px solid #CC3333; + font-weight: bolder; + text-align: center; + color: #CC3333; +} + +header p { + font-size: 30px; + margin: auto; + padding-top: 30px; + padding-bottom: 5px; +} + +header nav ul li { + font-size: 18px; + list-style-type: none; + display: inline-block; + padding-left: 20px; + padding-right: 20px; +} + +header nav ul li a:link { + text-decoration: none; + color: #CC3333; +} + +footer { + font-size: 15px; + color: #333333; + text-align: center; + margin-top: 100px; + line-height: 0.5; +} + +/*Section B: Content display for body's container*/ +main { + color: #333333; + line-height: 1.5; +} + +main h1 { + text-align: center; + font-size: 25px; +} + +main a:link { + text-decoration: none; + color: #CC3333; +} + +table { + border-collapse: collapse; + width: auto; +} + +th, td { + text-align: left; + padding: 15px; + border: 1px solid #CCCCCC; +} + +th { + font-weight: 600; + font-weight: bold; + color: black; + background-color: #CCCCCC; + border: 1px solid #F1F2F2; +} +/*Section C: This is the Overview page*/ + +.overview { + text-align: center; + margin-top: 50px; +} + +.overview li { + font-size: 25px; + list-style-type: none; + display: inline-block; + margin: 20px; + padding: 15px; + border: 2px solid #CC3333; +} + +.overview li a:link { + text-decoration: none; + color: #333333; +} + +.overview li a:visited { + text-decoration: none; + color: #333333; +} + + +/*MISC*/ + +a:hover { + background: #CCCCCC; +} + /* * This is a manifest file that'll be compiled into application.css, which will include all the files * listed below. diff --git a/app/assets/stylesheets/markets.scss b/app/assets/stylesheets/markets.scss new file mode 100644 index 00000000..98116b70 --- /dev/null +++ b/app/assets/stylesheets/markets.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the Markets controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/assets/stylesheets/products.scss b/app/assets/stylesheets/products.scss new file mode 100644 index 00000000..bff386e5 --- /dev/null +++ b/app/assets/stylesheets/products.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the Products controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/assets/stylesheets/sales.scss b/app/assets/stylesheets/sales.scss new file mode 100644 index 00000000..6f3405b9 --- /dev/null +++ b/app/assets/stylesheets/sales.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the sales controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/assets/stylesheets/vendors.scss b/app/assets/stylesheets/vendors.scss new file mode 100644 index 00000000..94dd8d0b --- /dev/null +++ b/app/assets/stylesheets/vendors.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the Vendor controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/controllers/.DS_Store b/app/controllers/.DS_Store new file mode 100644 index 00000000..4433ed77 Binary files /dev/null and b/app/controllers/.DS_Store differ diff --git a/app/controllers/markets_controller.rb b/app/controllers/markets_controller.rb new file mode 100644 index 00000000..a9a36b4b --- /dev/null +++ b/app/controllers/markets_controller.rb @@ -0,0 +1,77 @@ +class MarketsController < ApplicationController + def overview + end + + def view_markets # show all markets + @markets = Market.all + end + + def view_market # show a market + @market = Market.find(params[:id]) + @vendors = @market.vendors + end + + def index + @markets = Market.all + end + + def show + @market = Market.find(params[:id]) + end + + def new + @market = Market.new + end + + def create + @market = Market.new(market_params) + if @market.save + redirect_to markets_path + else + render :new + end + end + + def edit # + @market = Market.find(params[:id]) + end + + def update # + @market = Market.find(params[:id]) + if @market.update(market_params) + redirect_to markets_path + else + render :edit + end + end + + def market_vendors + @market = Market.find(params[:id]) + @vendors = @market.vendors + end + + def market_new_vendor + @market = Market.find(params[:id]) + @vendor = @market.vendors.build + end + + def market_create_vendor + @market = Market.find(params[:id]) + @vendor = @market.vendors.build(vendor_params) + if @vendor.save + redirect_to market_view_vendors_path + else + render :market_new_vendor + end + end + + private + + def market_params + params.require(:market).permit(:ref_id, :name, :address, :city, :county, :state, :zip) + end + + def vendor_params + params.require(:vendor).permit(:ref_id, :name, :num_employees, :market_id) + end +end diff --git a/app/controllers/products_controller.rb b/app/controllers/products_controller.rb new file mode 100644 index 00000000..55125a90 --- /dev/null +++ b/app/controllers/products_controller.rb @@ -0,0 +1,54 @@ +class ProductsController < ApplicationController + + def index + @vendor = Vendor.find(params[:vendor_id]) + @products = @vendor.products + end + + def new + @vendor = Vendor.find(params[:vendor_id]) + @product = @vendor.products.build + end + + def create + @vendor = Vendor.find(params[:vendor_id]) + @product = @vendor.products.new(prod_params) + if @product.save + # SAVED SUCCESSFULLY + redirect_to vendor_products_path + else + # DID NOT SAVE + puts @product.errors.messages + render :new + end + end + + def edit + @vendor = Vendor.find(params[:vendor_id]) + @product = Product.find(params[:id]) + end + + def update + @vendor = Vendor.find(params[:vendor_id]) + @product = Product.find(params[:id]) + if @product.update(prod_params) + # SUCCESS + redirect_to vendor_products_path + else + # NOPE + render :edit + end + end + + def destroy + Product.find(params[:id]).destroy + redirect_to vendor_products_path + end + + private + + def prod_params + params.require(:product).permit(:ref_id, :name, :vendor_id) + end + +end diff --git a/app/controllers/sales_controller.rb b/app/controllers/sales_controller.rb new file mode 100644 index 00000000..feb57abd --- /dev/null +++ b/app/controllers/sales_controller.rb @@ -0,0 +1,32 @@ +class SalesController < ApplicationController + + def index + @vendor = Vendor.find(params[:vendor_id]) + @sales = @vendor.sales + end + + def new + @vendor = Vendor.find(params[:vendor_id]) + @sale = @vendor.sales.build + end + + def create + @vendor = Vendor.find(params[:vendor_id]) + @sale = @vendor.sales.new(sale_params) + if @sale.save + # SAVED SUCCESSFULLY + redirect_to vendor_sales_path + else + # DID NOT SAVE + puts @sale.errors.messages + render :new + end + end + + private + + def sale_params + params.require(:sale).permit(:ref_id, :product_id, :vendor_id, :amount, :purchase_time) + end + +end diff --git a/app/controllers/vendors_controller.rb b/app/controllers/vendors_controller.rb new file mode 100644 index 00000000..2450b332 --- /dev/null +++ b/app/controllers/vendors_controller.rb @@ -0,0 +1,60 @@ +class VendorsController < ApplicationController + + def index + @vendors = Vendor.all + end + + def show + @vendor = Vendor.find(params[:id]) + @products = @vendor.products + end + + def view_products + @vendor = Vendor.find(params[:id]) + @products = @vendor.products + end + + # This is double ^^ revisit routes + + def new + @vendor = Vendor.new + end + + def create + @vendor = Vendor.new(vend_params) + if @vendor.save + # SAVED SUCCESSFULLY + else + # DID NOT SAVE + render :new + end + + redirect_to vendors_path + end + + def edit + @vendor = Vendor.find(params[:id]) + end + + def update + @vendor = Vendor.find(params[:id]) + if @vendor.update(vend_params) + # SUCCESS + redirect_to vendors_path + else + # NOPE + render :edit + end + end + + def destroy + Vendor.find(params[:id]).destroy + redirect_to vendors_path + end + + private + + def vend_params + params.require(:vendor).permit(:ref_id, :name, :num_employees, :market_id) + end +end diff --git a/app/helpers/markets_helper.rb b/app/helpers/markets_helper.rb new file mode 100644 index 00000000..655b79b7 --- /dev/null +++ b/app/helpers/markets_helper.rb @@ -0,0 +1,2 @@ +module MarketsHelper +end diff --git a/app/helpers/products_helper.rb b/app/helpers/products_helper.rb new file mode 100644 index 00000000..ab5c42b3 --- /dev/null +++ b/app/helpers/products_helper.rb @@ -0,0 +1,2 @@ +module ProductsHelper +end diff --git a/app/helpers/sales_helper.rb b/app/helpers/sales_helper.rb new file mode 100644 index 00000000..8611c4a0 --- /dev/null +++ b/app/helpers/sales_helper.rb @@ -0,0 +1,2 @@ +module SalesHelper +end diff --git a/app/helpers/vendors_helper.rb b/app/helpers/vendors_helper.rb new file mode 100644 index 00000000..5429ffa4 --- /dev/null +++ b/app/helpers/vendors_helper.rb @@ -0,0 +1,2 @@ +module VendorsHelper +end diff --git a/app/models/market.rb b/app/models/market.rb new file mode 100644 index 00000000..bc1d0136 --- /dev/null +++ b/app/models/market.rb @@ -0,0 +1,8 @@ +class Market < ActiveRecord::Base + has_many :vendors + + def all_vendors + self.vendors + end + +end diff --git a/app/models/product.rb b/app/models/product.rb new file mode 100644 index 00000000..29761393 --- /dev/null +++ b/app/models/product.rb @@ -0,0 +1,5 @@ +class Product < ActiveRecord::Base + belongs_to :vendor + has_many :sales + +end diff --git a/app/models/sale.rb b/app/models/sale.rb new file mode 100644 index 00000000..11a86503 --- /dev/null +++ b/app/models/sale.rb @@ -0,0 +1,5 @@ +class Sale < ActiveRecord::Base + belongs_to :vendor + belongs_to :product + +end diff --git a/app/models/vendor.rb b/app/models/vendor.rb new file mode 100644 index 00000000..d9054bb8 --- /dev/null +++ b/app/models/vendor.rb @@ -0,0 +1,9 @@ +class Vendor < ActiveRecord::Base + belongs_to :market + has_many :products + has_many :sales + + def self.products + products + end +end diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 443f3152..601fc48a 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -2,13 +2,38 @@
FARMAR DATABASE
+ ++ <%= t.label "Reference ID" %> + <%= t.text_field :ref_id %> +
+ ++ <%= t.label "Name" %> + <%= t.text_field :name %> +
+ + ++ <%= t.label "Address" %> + <%= t.text_field :address %> +
+ ++ <%= t.label "City" %> + <%= t.text_field :city %> +
+ ++ <%= t.label "County" %> + <%= t.text_field :county %> +
+ ++ <%= t.label "State" %> + <%= t.text_field :state %> +
+ ++ <%= t.label "Zip" %> + <%= t.text_field :zip %> +
+ + <%= t.submit "Submit" %> + +<% end %> diff --git a/app/views/markets/edit.html.erb b/app/views/markets/edit.html.erb new file mode 100644 index 00000000..37949f50 --- /dev/null +++ b/app/views/markets/edit.html.erb @@ -0,0 +1,7 @@ ++ <%= link_to "Return to Markets Overview", markets_path %> +
+ +<%= render partial: "form", locals: { http_method: :patch} %> diff --git a/app/views/markets/index.html.erb b/app/views/markets/index.html.erb new file mode 100644 index 00000000..016254e4 --- /dev/null +++ b/app/views/markets/index.html.erb @@ -0,0 +1,23 @@ ++ <%= link_to "Create a new Market entry", new_market_path %> +
+ + +Name | +Details | +Update | +
---|---|---|
<%= market.name %> | +<%= link_to "View", market_path(market) %> | +<%= link_to "Edit", edit_market_path(market) %> | +
+ + <%# v.label :name %> + <%= v.text_field :name %> +
+ ++ + <%# v.label "Reference ID" %> + <%= v.text_field :ref_id %> +
+ ++ + <%# v.label :num_employees %> + <%= v.text_field :num_employees %> +
+ ++ + <%# v.label "Market ID" %> + <%= v.text_field :market_id %> +
+ ++ <%= v.submit "Submit" %> +
+<% end %> + ++ <%= link_to "Return to list of Vendors participating in #{@market.name}", market_view_vendors_path%> +
+ ++ <%= link_to "Return to #{@market.name}", market_path%> +
diff --git a/app/views/markets/market_vendors.html.erb b/app/views/markets/market_vendors.html.erb new file mode 100644 index 00000000..35cba285 --- /dev/null +++ b/app/views/markets/market_vendors.html.erb @@ -0,0 +1,20 @@ ++ <%= link_to "Return to #{@market.name}", market_path %> +
+ +Name | +Number of Employees | +Update | +
---|---|---|
<%= vendor.name %> | +<%= vendor.num_employees %> | +<%= link_to "Edit", edit_vendor_path(vendor) %>, <%= link_to "Delete", vendor_path(vendor), method: :delete, data: { confirm: "Are you sure you want to delete the vendor?" } %> | +
+ <%= link_to "Return to Markets Overview", markets_path%> +
+ +<%= render partial: "form", locals: { http_method: :post } %> diff --git a/app/views/markets/overview.html.erb b/app/views/markets/overview.html.erb new file mode 100644 index 00000000..0690960e --- /dev/null +++ b/app/views/markets/overview.html.erb @@ -0,0 +1,5 @@ ++ <%= link_to "Edit this Market entry", edit_market_path %> +
+ +Name | +<%= @market.name %> | +
---|---|
Address | +<%= @market.address %> | +
City | +<%= @market.city %> | +
County | +<%= @market.county %> | +
State | +<%= @market.state %> | +
Zip | +<%= @market.zip %> | +
+ <%= link_to "View all Vendors participating in this Market", market_view_vendors_path %> +
+ +<%= link_to "Create a new Vendor", market_new_vendor_path %>
diff --git a/app/views/markets/view_market.html.erb b/app/views/markets/view_market.html.erb new file mode 100644 index 00000000..2d50e25e --- /dev/null +++ b/app/views/markets/view_market.html.erb @@ -0,0 +1,49 @@ ++ <%= link_to "Return to Markets Overview", view_all_markets_path %> +
+ +Name | +<%= @market.name %> | +
---|---|
Address | +<%= @market.address %> | +
City | +<%= @market.city %> | +
County | +<%= @market.county %> | +
State | +<%= @market.state %> | +
Zip | +<%= @market.zip %> | +
+ Vendors participating in <%= @market.name %>: +
+Vendors | +
---|
<%= vendor.name %> | +
+ Click on a Market to see details +
+<%= link_to market.name, view_market_path(market) %> | +
<%= p.label :name %> + <%= p.text_field :name %>
+ ++ <%= p.submit "Submit" %> +
+<% end %> diff --git a/app/views/products/edit.html.erb b/app/views/products/edit.html.erb new file mode 100644 index 00000000..103015de --- /dev/null +++ b/app/views/products/edit.html.erb @@ -0,0 +1,5 @@ +<%= link_to "Return to Vendor's list of Products", vendor_products_path(@vendor.id) %>
diff --git a/app/views/products/index.html.erb b/app/views/products/index.html.erb new file mode 100644 index 00000000..7b1e84dd --- /dev/null +++ b/app/views/products/index.html.erb @@ -0,0 +1,26 @@ +<%= link_to "Create New Product", new_vendor_product_path(@vendor.id) %>
+ +Name | +New Sale | +Update | +
---|---|---|
<%= product.name %> | +<%= link_to "Create", new_vendor_sale_path(@vendor) %> | +<%= link_to "Edit", edit_vendor_product_path(@vendor, product) %>, <%= link_to "Delete", vendor_product_path(@vendor, product), method: :delete, data: { confirm: "Are you sure you want to delete the product?" } %> | +
<%= link_to "See list of vendor's sales", vendor_sales_path(@vendor.id) %>
+ +<%= link_to "Return to Vendor page", vendor_path(@vendor.id) %>
diff --git a/app/views/products/new.html.erb b/app/views/products/new.html.erb new file mode 100644 index 00000000..d74d1692 --- /dev/null +++ b/app/views/products/new.html.erb @@ -0,0 +1,5 @@ ++ <%= link_to "Return to Products page", vendor_products_path %> +
+ +<%= link_to "Return to Vendor page", vendor_path(@vendor.id) %>
+ +Amount | +Purchase Date | +
---|---|
<%= "$#{sprintf('%.2f' % (s.amount/100.0))}" %> | +<%= s.purchase_time.strftime("%m/%d/%Y") %> | + <% total += s.amount %> +
<%= "Total sales: $#{ sprintf('%.2f' % (total/100.0)) }" %>
+ ++
Amount | +Purchase Date | +
---|---|
<%= "$#{sprintf('%.2f' % (ms.amount/100.0))}" %> | +<%= ms.purchase_time.strftime("%m/%d/%Y") %> | + <% monthly_total += ms.amount %> +
<%= "Monthly total: $#{ sprintf('%.2f' % (monthly_total/100.0)) }" %>
+ + <% else %> + <%= "No sales so far this month" %> + <% end %> diff --git a/app/views/sales/new.html.erb b/app/views/sales/new.html.erb new file mode 100644 index 00000000..656593fe --- /dev/null +++ b/app/views/sales/new.html.erb @@ -0,0 +1,17 @@ +<%= s.label :amount %> + <%= s.text_field :amount %>
+ ++ <%= s.label "Purchase date" %> + <%= s.date_field :purchase_time %> +
+ ++ <%= s.submit "Submit" %> +
+<% end %> + +<%= link_to "Return to Vendor's list of Products", vendor_products_path(@vendor.id) %>
diff --git a/app/views/vendors/_form.html.erb b/app/views/vendors/_form.html.erb new file mode 100644 index 00000000..2c2d235d --- /dev/null +++ b/app/views/vendors/_form.html.erb @@ -0,0 +1,14 @@ +<%= form_for @vendor do |v| %> +<%= v.label "Name" %> + <%= v.text_field :name %>
+ +<%= v.label "Number of employees" %> + <%= v.text_field :num_employees %>
+ +<%= v.label "Market ID" %> + <%= v.text_field :market_id %>
+ ++ <%= v.submit "Submit" %> +
+<% end %> diff --git a/app/views/vendors/edit.html.erb b/app/views/vendors/edit.html.erb new file mode 100644 index 00000000..dd6b528f --- /dev/null +++ b/app/views/vendors/edit.html.erb @@ -0,0 +1,5 @@ +<%= link_to "Return to Vendor page", vendor_path(@vendor.id) %>
diff --git a/app/views/vendors/index.html.erb b/app/views/vendors/index.html.erb new file mode 100644 index 00000000..54b2f170 --- /dev/null +++ b/app/views/vendors/index.html.erb @@ -0,0 +1,35 @@ ++ <%= link_to "Create a new Vendor entry", new_vendor_path %> +
+ ++ Name + | ++ Vendor's details + | ++ Products & Sales details + | ++ Update + | +
---|---|---|---|
<%= "#{ v.name.capitalize } " %> | +<%= link_to "View Vendor", vendor_path(v) %> | +<%= link_to "View Products & Sales", vendor_products_path(v) %> | +<%= link_to "Edit", edit_vendor_path(v) %>, <%= link_to "Delete", vendor_path(v), method: :delete, data: { confirm: "Are you sure you want to delete the vendor?" } %> | +
<%= link_to "Edit this Vendor entry", edit_vendor_path(@vendor)%>
+Number of employees | +<%= @vendor.num_employees %> | +
---|---|
Market ID | +<%= @vendor.market_id %> | +
<%= link_to "View Products", vendor_view_products_path(@vendor.id) %>
+ +<%= link_to "View Sales", vendor_sales_path(@vendor.id) %>
diff --git a/app/views/vendors/view_products.html.erb b/app/views/vendors/view_products.html.erb new file mode 100644 index 00000000..1d4ca16b --- /dev/null +++ b/app/views/vendors/view_products.html.erb @@ -0,0 +1,23 @@ + + ++ <%= link_to "Return to Vendor", vendor_path %> +
+ +