-
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
FarMar Rails #16
base: hrwdfcp/master
Are you sure you want to change the base?
FarMar Rails #16
Changes from all commits
f626e27
0a9b8b3
6f5be76
f7e9314
4bda5b2
1478e50
509cf9a
094811c
ef633e4
91d6f89
d85131a
9235a2b
0a97811
ee6931f
f56d86d
bbd21b8
3f871a7
2127ae5
5d76026
9918ef3
1f0103f
99fd97a
aed7cc0
88bbc0a
3fc8ed5
a590bbc
b321b20
0a04e66
c7e8403
19ee041
375cc78
7358d1f
7f3982d
33376aa
00cd0bd
3596906
f8c4ab9
ecc6f85
4cff0c9
0f8b93d
6d1ef13
d61c014
a25e75f
69d9be7
14f4330
b8ec16c
118a3be
7946c74
e7296e4
568d43f
086d9ad
02541a4
2b46d78
dfad819
98429b2
f6fd737
20195e1
5a1a334
8bfc9ec
f7fa6b0
10ab87e
e739729
498251a
826e2b1
2584e62
2642e2f
b9e6a29
f1905c2
c555f53
bc5b4c4
93a2100
f2adfc2
e936403
3be9d74
6f88fb8
3f0b45e
6352f8d
382c6e9
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/ |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* | ||
* 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 | ||
*/ | ||
body { | ||
font-family: 'Old Standard TT', serif; | ||
background-image: image-url("apple_black.jpeg"); | ||
-webkit-background-size: cover; | ||
-moz-background-size: cover; | ||
-o-background-size: cover; | ||
background-size: cover; | ||
color: #F0F0F0; | ||
background-color: #251B4A; | ||
background-attachment: fixed; | ||
cursor: image-url("apple.png"), auto | ||
} | ||
img{ | ||
width: 100%; | ||
height: 100%; | ||
} | ||
.index { | ||
line-height: 200%; | ||
|
||
} | ||
a { | ||
color: #F2F2F2; | ||
text-decoration: none; | ||
|
||
} | ||
|
||
a:hover {color: #20c98e} | ||
h1{ | ||
font-family: 'Pacifico', cursive; | ||
font-size: 40px; | ||
} | ||
.home-page-head{ | ||
margin-top: 150px; | ||
font-family: 'Pacifico', cursive; | ||
font-size: 75px; | ||
} | ||
.home-page{ | ||
font-family: 'Pacifico', cursive; | ||
font-size: 20px; | ||
text-decoration: none; | ||
display: inline; | ||
padding: 0 50px; | ||
background-color: #F0F0F0; | ||
color: #6B1629; | ||
} |
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 |
---|---|---|
@@ -1,2 +1,69 @@ | ||
class MarketsController < ApplicationController | ||
def home | ||
end | ||
def index | ||
@markets = Market.all | ||
@market_link = true | ||
@url = "" | ||
end | ||
|
||
def show | ||
id = params[:id] | ||
@market = Market.find(id) | ||
@vendors = @market.vendors | ||
@buttons = true | ||
|
||
#@delete_vendor = "DESTROY vendor is coming soon!" | ||
#@create_vendor = "ADD a vendor is coming soon!" | ||
#@edit_vendor = "EDIT a vendor is coming soon!" | ||
end | ||
|
||
def user_view | ||
@url = "/user_show" | ||
@markets = Market.all | ||
@market_link = false | ||
render "index" | ||
end | ||
|
||
def user_show | ||
id = params[:id] | ||
@market = Market.find(id) | ||
@vendors = @market.vendors | ||
@buttons = false | ||
render "show" | ||
end | ||
|
||
def create | ||
Market.create(market_params[:market]) | ||
redirect_to markets_path | ||
end | ||
|
||
def new | ||
@market = Market.new | ||
@action = "create" | ||
@method = :post | ||
@title = "Market Information" | ||
end | ||
|
||
def edit | ||
@title = "Edit your market" | ||
id = params[:id] | ||
@action = "update" | ||
@method = :patch | ||
@market = Market.find(id) | ||
render "new" | ||
end | ||
|
||
def update | ||
Market.update(params[:id], market_params[:market]) | ||
#redirect_to '/' | ||
redirect_to market_path(params[:id]) | ||
end | ||
|
||
private | ||
|
||
def market_params | ||
#this makes strong 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,40 @@ | ||
class ProductsController < ApplicationController | ||
def new | ||
@header = "Add A New Product" | ||
@product = Product.new | ||
@action = "create" | ||
@method = :post | ||
end | ||
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. Watch your whitespace in this class - there should be one line of whitespace between each method defitinition |
||
def edit | ||
@header = "Edit Product" | ||
id = params[:id] | ||
@product = Product.find(id) | ||
@action = "update" | ||
@method = :patch | ||
render "new" | ||
end | ||
def create | ||
id = params[:vendor_id] | ||
vendor = Vendor.find(id) | ||
vendor.products.create(product_params) | ||
redirect_to vendor_path(id) | ||
end | ||
def update | ||
id = params[:vendor_id] | ||
vendor = Vendor.find(id) | ||
product = vendor.products.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. I'm curious why you decided to go through the vendor to retrieve the product. Would there ever be a scenario where this product was not already associated with this vendor? |
||
product.update(product_params) | ||
redirect_to vendor_path(id) | ||
end | ||
def destroy | ||
id = params[:id] | ||
vendor_id = params[:vendor_id] | ||
Product.find(id).destroy | ||
redirect_to vendor_path(vendor_id) | ||
end | ||
|
||
private | ||
def product_params | ||
params.require(:product).permit(: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 | ||
@vendor = Vendor.find(params[:vendor_id]) | ||
@product = Product.find(params[:product_id]) | ||
end | ||
|
||
def create | ||
id = params[:product_id] | ||
product = Product.find(id) | ||
product.sales.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. I'm curious what made you decide to switch from |
||
#Sale.create( | ||
product_id: sale_params[:sale][:product_id], | ||
amount: sale_params[:sale][:amount].to_f * 100, | ||
vendor_id: params[:vendor_id], | ||
purchase_time: Time.now) | ||
redirect_to vendor_path(params[:vendor_id]) | ||
end | ||
|
||
private | ||
def sale_params | ||
params.permit(sale:[:product_id, :amount]) | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,50 @@ | ||
class VendorsController < ApplicationController | ||
def index | ||
@vendors = Vendor.all | ||
end | ||
def show | ||
id = params[:id] | ||
@vendor = Vendor.find(id) | ||
end | ||
|
||
|
||
def create | ||
market = Market.find(params[:market_id]) | ||
market.vendors.create(vendor_params) | ||
redirect_to market_path(params[:market_id]) | ||
end | ||
|
||
|
||
def new | ||
@vendor = Vendor.new | ||
@action = "create" | ||
@method = :post | ||
@title = "Vendor Information" | ||
end | ||
|
||
def edit | ||
@title = "Edit Vendor" | ||
id = params[:id] | ||
@action = "update" | ||
@method = :patch | ||
@vendor = Vendor.find(id) | ||
render "new" | ||
end | ||
|
||
def update | ||
Vendor.update(params[:id], vendor_params) | ||
redirect_to market_path(params[:market_id]) | ||
end | ||
|
||
def destroy | ||
id = params[:id] | ||
@vendor =Vendor.find(id).destroy | ||
redirect_to market_path(params[:market_id]) | ||
end | ||
|
||
private | ||
def vendor_params | ||
#this makes strong params | ||
params.require(:vendor).permit(:name, :employees) | ||
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,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 | ||
belongs_to :vendor | ||
has_many :sales | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
class Sale < ActiveRecord::Base | ||
belongs_to :vendor | ||
belongs_to :product | ||
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 here - you want one line between each CSS rule