-
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
Submitting FarMar Rails for Emily & Sarah #19
base: ergsat/master
Are you sure you want to change the base?
Changes from all commits
8b626ea
4f7b992
b7a89dd
1bfb960
60dfccf
4d2d085
233134f
a49f60c
c1f535b
4553315
031efa1
c1189d7
391cf77
725796c
4a0b7bc
0c18cb2
9f4e218
d1a5451
4846775
ea5b9f3
ad9fb54
e77f334
71d7134
13c6750
e6d1fff
ca6a658
44c0e63
fde31bb
4c8c3e8
2e5351d
e29bbeb
63dcc78
d51531c
96c6457
5f77202
d7e4649
0f49816
3920686
410d687
e81cf40
05236ad
a9c343d
95ad978
670b146
4e5abfc
552b56f
4a19379
11f5bfd
8c9cb82
0598b3c
672a2bb
2e2cd95
43abbc1
20e5f57
3cbb302
0148e71
b920794
8deb24f
2c3a31c
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/ |
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,142 @@ | ||
// 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/ | ||
|
||
@import url('https://fonts.googleapis.com/css?family=Amatic+SC|Open+Sans'); | ||
|
||
body { | ||
font-family: 'Open Sans', sans-serif; | ||
background-image: image-url("p-patch.jpg"); | ||
background-size: cover; | ||
color: #004d00; | ||
} | ||
|
||
a:hover {text-decoration: underline; | ||
} | ||
|
||
a { | ||
text-decoration:none; | ||
color: #004d00; | ||
} | ||
|
||
nav { | ||
text-align: center; | ||
font-size: 16px; | ||
background-color: #004d00; | ||
border-radius: 5px; | ||
padding: 5px; | ||
} | ||
|
||
.nav_link { | ||
color: white; | ||
font-family: 'Open Sans'; | ||
} | ||
|
||
h1 { | ||
font-family: 'Amatic SC', sans-serif; | ||
text-align: center; | ||
font-size: 3em; | ||
} | ||
|
||
div.fade { | ||
width: 700px; | ||
background-color: rgba(255, 255, 255, .75); | ||
margin: 50px auto; | ||
padding: 15px 50px; | ||
border-radius: 10px; | ||
text-align: left; | ||
} | ||
|
||
div.button { | ||
display:inline-block; | ||
padding: 40px; | ||
border-radius: 10px; | ||
border-width: medium; | ||
margin: 10px; | ||
margin-bottom: 20px; | ||
text-align: center; | ||
|
||
} | ||
|
||
div.button > a { | ||
text-decoration: none; | ||
font-family: 'Amatic SC', sans-serif; | ||
color: #ffffff; | ||
font-weight: bold; | ||
font-size: 2em; | ||
} | ||
|
||
div.button > a:hover { | ||
font-size: 250%; | ||
} | ||
|
||
div.center{ | ||
text-align: center; | ||
} | ||
|
||
div.show_sales { | ||
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. For CSS styles that are multiple words, standards state that we should separate with the |
||
display:inline-block; | ||
padding: 20px; | ||
border-width: medium; | ||
border-radius: 10px; | ||
margin: 10px; | ||
text-align: center; | ||
background-color: rgba(184, 184, 148, .75) | ||
} | ||
|
||
li { | ||
line-height: 150%; | ||
} | ||
|
||
|
||
|
||
.market_button { | ||
background-color: rgba(41, 41, 163, .75); | ||
} | ||
|
||
.vendor_button{ | ||
background-color: rgba(0, 102, 34, .75); | ||
|
||
} | ||
|
||
.edit { | ||
color: #392613; | ||
} | ||
|
||
.delete { | ||
color: #cc3300; | ||
} | ||
|
||
form { | ||
margin: auto; | ||
padding: 0px 50px 0px 50px; | ||
line-height: 200%; | ||
} | ||
|
||
fieldset { | ||
padding-bottom: 20px; | ||
border: 0; | ||
} | ||
|
||
legend { | ||
padding: 10px; | ||
} | ||
|
||
label { | ||
margin-left: 10px; | ||
} | ||
|
||
input { | ||
border: none; | ||
border-glow: none; | ||
background-color: rgba(0, 102, 34, .4); | ||
outline: none; | ||
padding: 5px; | ||
font-size: 1.05em; | ||
border-radius: 5px; | ||
margin: 10px; | ||
} | ||
|
||
.submit_button { | ||
font-family: 'Open Sans' | ||
} |
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 |
---|---|---|
@@ -0,0 +1,57 @@ | ||
class MarketsController < ApplicationController | ||
|
||
def home | ||
@markets = Market.all | ||
end | ||
|
||
def show | ||
id = params[:id] | ||
@market = Market.find(id) | ||
@vendors = @market.vendors | ||
end | ||
|
||
def index | ||
@is_a_market = true | ||
@markets = Market.all | ||
end | ||
|
||
def edit | ||
id = params[:id] | ||
@market= Market.find(id) | ||
@title = "Edit Market" | ||
@action = :update | ||
end | ||
|
||
def update | ||
Market.update(params[:id], market_params[:market] ) | ||
redirect_to market_path(params[:id]) | ||
end | ||
|
||
def new | ||
id = params[:id] | ||
@market= Market.new | ||
@title = "Create a Market" | ||
@action = :create | ||
end | ||
|
||
def view | ||
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. I'm curious why this method is a duplicate for |
||
show | ||
end | ||
|
||
def create | ||
a = Market.create( market_params[: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. Recommend updating to use a more meaningful variable name rather than |
||
redirect_to market_path(a.id) | ||
end | ||
|
||
def destroy | ||
Market.destroy(params[:id]) | ||
redirect_to markets_path | ||
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 routes in this controller! |
||
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,44 @@ | ||
class ProductsController < ApplicationController | ||
|
||
def new | ||
@product = Product.new | ||
end | ||
|
||
def edit | ||
id = params[:id] | ||
@product = Product.find(id) | ||
@title = "Edit Product" | ||
@action = :update | ||
end | ||
|
||
def update | ||
id = params[:id] | ||
product = Product.find(id) | ||
vendor_id = product.vendor_id | ||
Product.update(params[:id], product_params[:product]) | ||
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. You have a local variable for the |
||
redirect_to vendor_path(vendor_id) | ||
end | ||
|
||
def create | ||
Product.create(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 | ||
|
||
def show | ||
@product = Product.find(params[:id]) | ||
@sales = @product.sales | ||
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. You can access the sales from the Product so it seems like you don't need this additional instance variable |
||
end | ||
|
||
private | ||
|
||
def product_params | ||
params.permit(product:[:id, :name, :vendor_id]) | ||
end | ||
|
||
|
||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
class SalesController < ApplicationController | ||
|
||
def new | ||
@sale = Sale.new | ||
end | ||
|
||
def create | ||
a = Sale.create( | ||
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. Similar comment re: variable naming with a meaningful name |
||
:amount => ((sale_params[:sale][:amount]).to_i * 100), | ||
:purchase_time => sale_params[:sale][:purchase_time], | ||
:vendor_id => sale_params[:sale][:vendor_id], | ||
:product_id => sale_params[:sale][:product_id], | ||
|
||
) | ||
redirect_to vendor_product_path(a.vendor_id, a.product_id) | ||
end | ||
|
||
private | ||
|
||
def sale_params | ||
params.permit(sale:[:amount, :purchase_time, :vendor_id, :product_id]) | ||
end | ||
|
||
|
||
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.
Watch your whitespace and formatting here