Skip to content
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

Open
wants to merge 78 commits into
base: hrwdfcp/master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
f626e27
Add models for market and vendor
dezshino Nov 18, 2015
0a9b8b3
Fix models, create schema
dezshino Nov 18, 2015
6f5be76
delete unneccessary csv files
yourFriendWes Nov 18, 2015
f7e9314
generate models for product and sales
yourFriendWes Nov 18, 2015
4bda5b2
add active record relationships
yourFriendWes Nov 18, 2015
1478e50
seed csv data
yourFriendWes Nov 18, 2015
509cf9a
Add routes for markets and vendors
dezshino Nov 18, 2015
094811c
Update gemfiles with better_errors
dezshino Nov 18, 2015
ef633e4
Change root route, update views for home and markets index
dezshino Nov 18, 2015
91d6f89
Add methods to markets and vendors controllers
dezshino Nov 18, 2015
d85131a
Add view pages for show,new, and edit for markets and vendors
dezshino Nov 18, 2015
9235a2b
Add link from markets index to market show page, display market info …
dezshino Nov 18, 2015
0a97811
Differentiate views for general user and market-user
dezshino Nov 18, 2015
ee6931f
Link to vendor show page from vendors index page,create a vendor show…
dezshino Nov 18, 2015
f56d86d
differentiate show view for user and market
yourFriendWes Nov 18, 2015
bbd21b8
Merge branch 'hrwdfcp/master' of github.com:desireepoland/FarMarRails…
yourFriendWes Nov 18, 2015
3f871a7
Add vendor products and sales info to Vendor Show page
dezshino Nov 18, 2015
2127ae5
Merge branch 'hrwdfcp/master' of github.com:desireepoland/FarMarRails…
yourFriendWes Nov 18, 2015
5d76026
Merge pull request #1 from desireepoland/hailey
dezshino Nov 18, 2015
9918ef3
Set up view for Vendor show page
dezshino Nov 18, 2015
1f0103f
Refactor adding vendor sales
dezshino Nov 19, 2015
99fd97a
differentiate user show and market show
yourFriendWes Nov 19, 2015
aed7cc0
Merge branch 'hrwdfcp/master' of github.com:desireepoland/FarMarRails…
yourFriendWes Nov 19, 2015
88bbc0a
Create controllers for products and sales, nest products and sales ro…
dezshino Nov 19, 2015
3fc8ed5
Update routes to have sales nested inside products, add actions to sa…
dezshino Nov 19, 2015
a590bbc
add form to create new market
yourFriendWes Nov 19, 2015
b321b20
add form to edit market
yourFriendWes Nov 19, 2015
0a04e66
Change Vendor product info into a table instead of list
dezshino Nov 19, 2015
c7e8403
Merge branch 'hrwdfcp/master' of github.com:desireepoland/FarMarRails…
yourFriendWes Nov 19, 2015
19ee041
Change vendor sales into table
dezshino Nov 19, 2015
375cc78
add link on show page to update market
yourFriendWes Nov 19, 2015
7358d1f
Add files for views for products and sales
dezshino Nov 19, 2015
7f3982d
Add form to create a new product, link to form from vendor show page
dezshino Nov 19, 2015
33376aa
add create and update vendor functions
yourFriendWes Nov 19, 2015
00cd0bd
Merge branch 'hrwdfcp/master' of github.com:desireepoland/FarMarRails…
yourFriendWes Nov 19, 2015
3596906
Fix form to create a new product for a specific vendor to save
dezshino Nov 19, 2015
f8c4ab9
fix delete vendor link in markets/show
yourFriendWes Nov 19, 2015
ecc6f85
add new and create methods for sale
yourFriendWes Nov 19, 2015
4cff0c9
Link to edit product page from vendor show page
dezshino Nov 19, 2015
0f8b93d
Merge branch 'hrwdfcp/master' of github.com:desireepoland/FarMarRails…
dezshino Nov 19, 2015
6d1ef13
Make the products update action work
dezshino Nov 19, 2015
d61c014
Add ability to delete a vendor's product
dezshino Nov 19, 2015
a25e75f
add method to add new product sale
yourFriendWes Nov 19, 2015
69d9be7
Change edit and delete link names to be symbols
dezshino Nov 19, 2015
14f4330
add method to add new product sale
yourFriendWes Nov 19, 2015
b8ec16c
Merge branch 'hrwdfcp/master' of github.com:desireepoland/FarMarRails…
yourFriendWes Nov 19, 2015
118a3be
add a new sale for product works
yourFriendWes Nov 19, 2015
7946c74
Format vendor show page to look nicer
dezshino Nov 20, 2015
e7296e4
Add Old Standard TT font to site
dezshino Nov 20, 2015
568d43f
Update style
dezshino Nov 20, 2015
086d9ad
nested vendor in market
yourFriendWes Nov 20, 2015
02541a4
add background image and font color
dezshino Nov 20, 2015
2b46d78
Add style to home page
dezshino Nov 20, 2015
dfad819
Add styling
dezshino Nov 20, 2015
98429b2
Chnage market show vendors list into a table, change edit and delete …
dezshino Nov 20, 2015
f6fd737
change monthly sales methods to vendor instance methods
yourFriendWes Nov 20, 2015
20195e1
Merge branch 'hrwdfcp/master' of github.com:desireepoland/FarMarRails…
yourFriendWes Nov 20, 2015
5a1a334
format display of monthly sales methods on vendor show view
yourFriendWes Nov 20, 2015
8bfc9ec
Fix background image to not repeat
dezshino Nov 20, 2015
f7fa6b0
change monthly and total sales to display as currency
yourFriendWes Nov 20, 2015
10ab87e
Merge branch 'hrwdfcp/master' of github.com:desireepoland/FarMarRails…
yourFriendWes Nov 20, 2015
e739729
Add a header of navigation links, re-style home page
dezshino Nov 20, 2015
498251a
add names to displays of product sales
yourFriendWes Nov 20, 2015
826e2b1
Merge branch 'hrwdfcp/master' of github.com:desireepoland/FarMarRails…
yourFriendWes Nov 20, 2015
2584e62
Re add the csrf_meta_tag
dezshino Nov 20, 2015
2642e2f
Take out extra space
dezshino Nov 20, 2015
b9e6a29
add styling to links
yourFriendWes Nov 20, 2015
f1905c2
update gemfiles
dezshino Nov 20, 2015
c555f53
Update stuff for heroku
dezshino Nov 20, 2015
bc5b4c4
Format background image to work with heroku
dezshino Nov 20, 2015
93a2100
add rails_12factor gem to gemfile
dezshino Nov 20, 2015
f2adfc2
fix seeds for heroku
dezshino Nov 20, 2015
e936403
add apple emoji to cursor
yourFriendWes Nov 20, 2015
3be9d74
Merge branch 'hrwdfcp/master' of github.com:desireepoland/FarMarRails…
yourFriendWes Nov 20, 2015
6f88fb8
update cursor image for heroku
dezshino Nov 20, 2015
3f0b45e
remove 'market id' field from create vendor form
yourFriendWes Nov 20, 2015
6352f8d
Merge branch 'hrwdfcp/master' of github.com:desireepoland/FarMarRails…
yourFriendWes Nov 20, 2015
382c6e9
fix market show to have correct vendor paths
yourFriendWes Nov 21, 2015
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
11 changes: 8 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
source 'https://rubygems.org'


gem 'csv'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.5'
# 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
Expand Down Expand Up @@ -35,13 +33,20 @@ 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'
gem 'sqlite3'
end

group :development do
# Access an IRB console on exception pages or by using <%= console %> in views
gem 'web-console', '~> 2.0'
gem 'better_errors'
gem 'binding_of_caller'

# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
end

group :production do
gem 'pg'
gem 'rails_12factor'
end
17 changes: 17 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,23 @@ GEM
thread_safe (~> 0.3, >= 0.3.4)
tzinfo (~> 1.1)
arel (6.0.3)
better_errors (2.1.1)
coderay (>= 1.0.0)
erubis (>= 2.6.6)
rack (>= 0.9.0)
binding_of_caller (0.7.2)
debug_inspector (>= 0.0.1)
builder (3.2.2)
byebug (8.2.0)
coderay (1.1.0)
coffee-rails (4.1.0)
coffee-script (>= 2.2.0)
railties (>= 4.0.0, < 5.0)
coffee-script (2.4.1)
coffee-script-source
execjs
coffee-script-source (1.10.0)
csv (2.7.3)
debug_inspector (0.0.2)
erubis (2.7.0)
execjs (2.6.0)
Expand All @@ -72,6 +78,7 @@ GEM
multi_json (1.11.2)
nokogiri (1.6.6.3)
mini_portile (~> 0.6.0)
pg (0.18.4)
rack (1.6.4)
rack-test (0.6.3)
rack (>= 1.0)
Expand All @@ -94,6 +101,11 @@ GEM
rails-deprecated_sanitizer (>= 1.0.1)
rails-html-sanitizer (1.0.2)
loofah (~> 2.0)
rails_12factor (0.0.3)
rails_serve_static_assets
rails_stdout_logging
rails_serve_static_assets (0.0.4)
rails_stdout_logging (0.0.4)
railties (4.2.5)
actionpack (= 4.2.5)
activesupport (= 4.2.5)
Expand Down Expand Up @@ -139,11 +151,16 @@ PLATFORMS
ruby

DEPENDENCIES
better_errors
binding_of_caller
byebug
coffee-rails (~> 4.1.0)
csv
jbuilder (~> 2.0)
jquery-rails
pg
rails (= 4.2.5)
rails_12factor
sass-rails (~> 5.0)
sdoc (~> 0.4.0)
spring
Expand Down
Binary file added app/.DS_Store
Binary file not shown.
Binary file added app/assets/.DS_Store
Binary file not shown.
Binary file added app/assets/images/.DS_Store
Binary file not shown.
Binary file added app/assets/images/apple.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/apple_black.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions app/assets/javascripts/products.coffee
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/
3 changes: 3 additions & 0 deletions app/assets/javascripts/sales.coffee
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/
15 changes: 0 additions & 15 deletions app/assets/stylesheets/application.css

This file was deleted.

60 changes: 60 additions & 0 deletions app/assets/stylesheets/application.css.scss
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;
}

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

.home-page{
font-family: 'Pacifico', cursive;
font-size: 20px;
text-decoration: none;
display: inline;
padding: 0 50px;
background-color: #F0F0F0;
color: #6B1629;
}
3 changes: 3 additions & 0 deletions app/assets/stylesheets/products.scss
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/
3 changes: 3 additions & 0 deletions app/assets/stylesheets/sales.scss
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/
67 changes: 67 additions & 0 deletions app/controllers/markets_controller.rb
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
40 changes: 40 additions & 0 deletions app/controllers/products_controller.rb
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

Choose a reason for hiding this comment

The 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])

Choose a reason for hiding this comment

The 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
25 changes: 25 additions & 0 deletions app/controllers/sales_controller.rb
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(

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm curious what made you decide to switch from Sale.create to product.sales.create? Was the association with the product not being created correctly?

#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
48 changes: 48 additions & 0 deletions app/controllers/vendors_controller.rb
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
2 changes: 2 additions & 0 deletions app/helpers/products_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module ProductsHelper
end
2 changes: 2 additions & 0 deletions app/helpers/sales_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module SalesHelper
end
3 changes: 3 additions & 0 deletions app/models/market.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class Market < ActiveRecord::Base
has_many :vendors
end
4 changes: 4 additions & 0 deletions app/models/product.rb
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
4 changes: 4 additions & 0 deletions app/models/sale.rb
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
Loading