-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FarMarRails #21
base: arhcas/master
Are you sure you want to change the base?
FarMarRails #21
Changes from all commits
fa56b21
51e841a
ba5a9bd
ff1f78a
a40c15d
7bcea25
02592f8
e75f30c
c46b23d
f4a7a6a
9fb719a
612b04f
bf2b56f
6902d12
9387916
c378e63
ec31fa8
2fd3983
d64be08
b1074bf
f2206d1
ea1b45d
0bdf861
486173d
755b71d
7a08131
0f35a8d
fcfae6f
92b8496
3e12f6c
5c60a8b
48aea68
6c6f1aa
c55834f
d958bed
51d662d
71fa8f8
0402cfa
436ab37
1d0badd
4fbf78a
7bb40a8
898a18c
1bf6e68
a07e17f
4734cea
5f2b0f0
56d4286
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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/ |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/* | ||
* This is a manifest file that'll be compiled into application.css, which will include all the files | ||
* listed below. | ||
* | ||
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets, | ||
* or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path. | ||
* | ||
* You're free to add application-wide styles to this file and they'll appear at the bottom of the | ||
* compiled file so the styles you add here take precedence over styles defined in any styles | ||
* defined in the other CSS/SCSS files in this directory. It is generally better to create a new | ||
* file per style scope. | ||
* | ||
*= require_tree . | ||
*= require_self | ||
*/ | ||
@import "bootstrap-sprockets"; | ||
@import "bootstrap"; | ||
@import url(https://fonts.googleapis.com/css?family=Montserrat); | ||
@import url(https://fonts.googleapis.com/css?family=EB+Garamond); | ||
@import url(https://fonts.googleapis.com/css?family=Fjalla+One); | ||
@import url(https://fonts.googleapis.com/css?family=PT+Serif); | ||
@import url(https://fonts.googleapis.com/css?family=Muli); | ||
|
||
|
||
body { | ||
font-family: 'PT Serif', serif; | ||
font-size: 16px; | ||
line-height: 23px; | ||
margin: 0 0 23px 0; | ||
margin: 0; | ||
background: image-url('blue.jpg'); | ||
background-size: 1440px 800px; | ||
display: compact; | ||
} | ||
|
||
div { | ||
background-color: #F1F2F2; | ||
opacity: 0.95; | ||
padding: 30px; | ||
margin: 60px; | ||
} | ||
|
||
.container { | ||
margin-top: 50px; | ||
margin-bottom: 20px; | ||
padding-bottom: 20px; | ||
} | ||
|
||
h1 { | ||
text-align: center; | ||
padding: 25px; | ||
padding-top: 40px; | ||
font-family: 'Muli', sans-serif; | ||
font-weight: normal; | ||
text-transform: uppercase; | ||
line-height: 50px; | ||
font-size: 50px; | ||
margin: 0 0 23px 0; | ||
} | ||
|
||
h2 { | ||
text-align: center; | ||
} | ||
|
||
.table-division { | ||
border-top-style: solid; | ||
border-top-width: medium; | ||
} | ||
|
||
footer { | ||
text-align: center; | ||
} | ||
|
||
.sales { | ||
font-family: 'Muli', sans-serif; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
// Place all the styles related to the Vendors controller here. | ||
// They will automatically be included in application.css. | ||
// You can use Sass (SCSS) here: http://sass-lang.com/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,58 @@ | ||
class MarketsController < ApplicationController | ||
|
||
def home | ||
|
||
end | ||
|
||
def index | ||
@is_market = true if session[:user_type] == "market" | ||
user = params[:user_type] | ||
session[:user_type] = user unless user.nil? | ||
@markets = Market.all | ||
|
||
end | ||
|
||
def show | ||
id = params[:id] | ||
@market = Market.find(id) | ||
@market = Market.find(params[:id]) | ||
@is_market = true if session[:user_type] == "market" | ||
@is_vendor = true if session[:user_type] == "vendor" | ||
@if_guest = true if session[:user_type] == "guest" | ||
end | ||
|
||
def new | ||
@market = Market.new | ||
end | ||
|
||
def create | ||
market = Market.create(market_params[:market]) | ||
redirect_to "/markets/#{market.id}" | ||
end | ||
|
||
def edit | ||
@market = Market.find(params[:id]) | ||
name = params[:name] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you need to populate each of these individual local variables? What/where are they being used? |
||
address = params[:address] | ||
city = params[:city] | ||
county = params[:county] | ||
state = params[:state] | ||
zip = params[:zip] | ||
end | ||
|
||
def update | ||
@market = Market.find(params[:id]) | ||
Market.update(params[:id], market_params[:market]) | ||
redirect_to "/markets/#{@market.id}" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there a named route which corresponds to this that you can use instead of the URL itself? |
||
end | ||
|
||
def destroy | ||
Market.destroy(params[:id]) | ||
redirect_to "/markets/" | ||
end | ||
|
||
private | ||
|
||
def market_params | ||
params.permit(market: [:name, :address, :city, :county, :state, :zip]) | ||
end | ||
|
||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
class ProductsController < ApplicationController | ||
def index | ||
@products = Product.all | ||
end | ||
|
||
def new | ||
@product = Product.new | ||
end | ||
|
||
def create | ||
product = Product.create(name: product_params[:product][:name], vendor_id: params[:vendor_id]) | ||
redirect_to vendor_path(params[:vendor_id]) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice use of the named route here |
||
end | ||
|
||
def edit | ||
@product = Product.find(params[:id]) | ||
name = params[:name] | ||
end | ||
|
||
def update | ||
@product = Product.find(params[:id]) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It seems like this |
||
Product.update(params[:id], product_params[:product]) | ||
redirect_to vendor_path(params[:vendor_id]) | ||
end | ||
|
||
def destroy | ||
Product.destroy(params[:id]) | ||
redirect_to vendor_path(params[:vendor_id]) | ||
end | ||
|
||
private | ||
|
||
def product_params | ||
params.permit(product: [:name]) | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
class SalesController < ApplicationController | ||
|
||
def index | ||
@vendor = Vendor.find(params[:vendor_id]) | ||
@is_market = true if session[:user_type] == "market" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same comment re: the if/elsif/else conditional |
||
@is_vendor = true if session[:user_type] == "vendor" | ||
@if_guest = true if session[:user_type] == "guest" | ||
end | ||
|
||
def new | ||
@sale = Sale.new | ||
@vendor = Vendor.find(params[:vendor_id]) | ||
end | ||
|
||
def create | ||
@sale = Sale.create(amount: sales_params[:sale][:amount], purchase_time: sales_params[:sale][:purchase_time], product_id: params[:product_id], vendor_id: params[:vendor_id]) | ||
redirect_to vendor_path(params[:vendor_id]) | ||
end | ||
|
||
private | ||
|
||
def sales_params | ||
params.permit(sale: [:amount, :purchase_time, :product_id, :vendor_id]) | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
class VendorsController < ApplicationController | ||
def index | ||
@vendors = Vendor.all | ||
@is_market = true if session[:user_type] == "market" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same comment re: the if/elsif/else conditional (also in show method below) |
||
@is_vendor = true if session[:user_type] == "vendor" | ||
@if_guest = true if session[:user_type] == "guest" | ||
end | ||
|
||
def show | ||
@vendor = Vendor.find(params[:id]) | ||
@market = Market.find(@vendor.market_id) | ||
@is_market = true if session[:user_type] == "market" | ||
@is_vendor = true if session[:user_type] == "vendor" | ||
@if_guest = true if session[:user_type] == "guest" | ||
end | ||
|
||
def new | ||
@vendor = Vendor.new | ||
end | ||
|
||
def create | ||
vendor = Vendor.create(vendor_params[:vendor]) | ||
redirect_to "/vendors/#{vendor.id}" | ||
end | ||
|
||
def edit | ||
@vendor = Vendor.find(params[:id]) | ||
name = params[:name] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are these local variables being used? |
||
employee_no = params[:employee_no] | ||
market_id = params[:market_id] | ||
end | ||
|
||
def update | ||
@vendor = Vendor.find(params[:id]) | ||
Vendor.update(params[:id], vendor_params[:vendor]) | ||
redirect_to "/vendors/#{@vendor.id}" | ||
end | ||
|
||
def destroy | ||
Vendor.destroy(params[:id]) | ||
redirect_to "/vendors/" | ||
end | ||
|
||
private | ||
|
||
def vendor_params | ||
params.permit(vendor: [:name, :employee_no, :market_id]) | ||
end | ||
|
||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
module ProductsHelper | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
module SalesHelper | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
module VendorsHelper | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
class Market < ActiveRecord::Base | ||
has_many :vendors | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
class Product < ActiveRecord::Base | ||
has_many :sales | ||
belongs_to :vendor | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By using the one-line conditionals here with the
if
s, your code will attempt execution on each individual conditional. The problem with this is that each conditional is actually mutually exclusive, so if the first one is true, it should not continue attempting to execute the rest of the conditionals.I think that an if/elsif/else condition would be better suited here.