Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
171 commits
Select commit Hold shift + click to select a range
b1d47b0
Recipe Seeds.
brittinator Jul 27, 2015
07566ad
WIP: home view.
brittinator Jul 28, 2015
b308ce7
WIP: home page, and users-show page.
brittinator Jul 28, 2015
083de61
WIP: home page and user dashboard views.
brittinator Jul 28, 2015
27b5174
WIP: user show page.
brittinator Jul 28, 2015
ad8f9b1
seed_photos
wangg131 Jul 28, 2015
f28391e
ingredient and recipe set up
wangg131 Jul 28, 2015
02e5baf
Merge branch 'recipe_all' into blw+lw/master
wangg131 Jul 28, 2015
babb480
deleted
wangg131 Jul 28, 2015
1db5554
setting up rails/rspec for recipe & ingredient controller and models
wangg131 Jul 28, 2015
0367f2a
Merge branch 'recipe_all' into blw+lw/master
wangg131 Jul 28, 2015
516f718
ingredient & recipe controller/model setup again
wangg131 Jul 28, 2015
73efddb
schema for ingredients and recipe
wangg131 Jul 28, 2015
22320f5
Merge branch 'recipe_all' into blw+lw/master
wangg131 Jul 28, 2015
69256bf
Add model table to schema: cookbook, user.
brittinator Jul 28, 2015
d70fafa
join table for cookbook_recipes.
brittinator Jul 28, 2015
fe96ceb
cookbook-recipe join table migration.
brittinator Jul 28, 2015
21781c9
seeds
wangg131 Jul 28, 2015
a153232
Merge branch 'recipe_all' into blw+lw/master
wangg131 Jul 28, 2015
6950194
recipe and ingredient seeds.
brittinator Jul 28, 2015
ff0eff4
Merge branch 'blw+lw/master' into seeds
brittinator Jul 28, 2015
bf6f721
sessions and users controllers
wangg131 Jul 28, 2015
94cc340
Adds seed data for: user, recipes, ingredients, and cookbooks.
brittinator Jul 28, 2015
4505b7b
WIP: join tables.
brittinator Jul 28, 2015
a195c73
WIP: seed and relational associations.
brittinator Jul 28, 2015
4d53214
sessions, users
wangg131 Jul 28, 2015
3a23f6c
mergin
wangg131 Jul 28, 2015
011118e
sign up working
wangg131 Jul 28, 2015
966807c
Adds associations for models.
brittinator Jul 28, 2015
3d282e3
signup path
wangg131 Jul 28, 2015
ec9ae35
WIP: seeding.
brittinator Jul 28, 2015
0579c2a
Merge branch 'seeding' into blw+lw/master
brittinator Jul 28, 2015
f065cad
user dashboard view
wangg131 Jul 28, 2015
120ba6b
Merge branch 'sessions-7-28' into blw+lw/master
wangg131 Jul 28, 2015
8d3ad13
WIP: ingredient model rspec.
brittinator Jul 29, 2015
0b053f2
WIP: rspec test for ingredient validation not working properly.
brittinator Jul 29, 2015
52c1a20
WIP: on the bus work. Ingredient controller CRUD and associated tests.
brittinator Jul 29, 2015
d57e855
WIP: ingredient controller.
brittinator Jul 29, 2015
78892f8
Adds alphabet scope to order ingredients alphabetically.
brittinator Jul 29, 2015
604d3c1
WIP: Adds ingredient rspec tests for controller.
brittinator Jul 29, 2015
21f1e65
Ingredient_controller_spec coverage 99.28% right now. Not many negati…
brittinator Jul 29, 2015
dfe48a0
Adds seeded recipes, cookbooks, users, and join tables for schema.
brittinator Jul 29, 2015
bf1cb9f
Merge pull request #1 from brittinator/ingred
brittinator Jul 29, 2015
1038c29
dashboard setup
wangg131 Jul 29, 2015
ad17767
taking out null from cookbooks table
wangg131 Jul 29, 2015
8ee8c8b
users dashboard wip
wangg131 Jul 29, 2015
b468190
sessions tests w/o factory girl..
wangg131 Jul 29, 2015
082cbeb
factory girl sessions test..?
wangg131 Jul 29, 2015
278503d
recipe controller and models wip
wangg131 Jul 29, 2015
17137a4
recipe model controller validations
wangg131 Jul 29, 2015
a55bb4a
moar recipe model and controller stuff
wangg131 Jul 29, 2015
ec52fb7
recipe model controller tests
wangg131 Jul 29, 2015
9521000
recipe controller
wangg131 Jul 29, 2015
e4296b5
Merge pull request #2 from brittinator/wang-7-28
wangg131 Jul 29, 2015
888b95b
mergin
wangg131 Jul 29, 2015
c354b63
search query
wangg131 Jul 29, 2015
3b0f8ce
working search bar
wangg131 Jul 29, 2015
23ab052
Nav bar not blocking page views. Partial for show pages.
brittinator Jul 29, 2015
5d6bfb7
index partial moar of it
wangg131 Jul 29, 2015
2666cca
ingredient index partial
wangg131 Jul 29, 2015
fc0503e
WIP: show partial.
brittinator Jul 29, 2015
773161c
WIP: show page.
brittinator Jul 29, 2015
b1aa30f
Adds show page for recipes, ingredients.
brittinator Jul 29, 2015
0eb3fc3
cookbook controller and model
wangg131 Jul 29, 2015
a93befc
recipes controller and model
wangg131 Jul 29, 2015
25e4efb
Merge branch 'index_partial' into blw+lw/master
wangg131 Jul 29, 2015
3f66e6b
Adds show user page for anonymous user.
brittinator Jul 29, 2015
db93da2
Adds show ingredient and show recipe page links.
brittinator Jul 29, 2015
0169494
new recipe association with ingredient wip
wangg131 Jul 30, 2015
f499349
Merge branch 'blw+lw/master' of github.com:brittinator/C3Projects--Ad…
wangg131 Jul 30, 2015
b533ca9
create new recipe with working association
wangg131 Jul 30, 2015
ee15b69
working new recipe form with association woo
wangg131 Jul 30, 2015
d510821
recipe form with association still saving two ingredients..
wangg131 Jul 30, 2015
ae3149b
recipe form with associations saving right
wangg131 Jul 30, 2015
e6fc4f3
case insensitive alphabetical scope
wangg131 Jul 30, 2015
d1d1a20
dashboard cookbooks view
wangg131 Jul 30, 2015
1340acd
only shows users cookbooks recipe#new
wangg131 Jul 30, 2015
5ad3c08
only users cookbooks on dashboard
wangg131 Jul 30, 2015
dd9c961
destroy cookbook wip
wangg131 Jul 30, 2015
0b92219
ingredient model specs
wangg131 Jul 30, 2015
c8b20d2
recipe controller and model specs
wangg131 Jul 30, 2015
eac4a11
working cookbook model spec
wangg131 Jul 30, 2015
6f7c96d
recipe controller specs wip
wangg131 Jul 30, 2015
0a017b5
moar cookbook model tests
wangg131 Jul 30, 2015
5b2effa
controller model and controller specs wip
wangg131 Jul 30, 2015
9060797
WIP: carrierwave uploader.
brittinator Jul 30, 2015
8aec805
Carrierwave on show page.
brittinator Jul 30, 2015
c33f95a
Adds images to the show recipe and index recipe pages.
brittinator Jul 30, 2015
2f9cc3d
User dashboard (show view) now includes recipe names, and some button…
brittinator Jul 30, 2015
3aa2e90
WIP: Cookbook show view and controller action.
brittinator Jul 30, 2015
6ba338f
WIP: cookbook show page.
brittinator Jul 30, 2015
703fa30
Adds image uploader to ingredients.
brittinator Jul 30, 2015
f80058b
Merge pull request #3 from brittinator/tests
wangg131 Jul 30, 2015
6dfc59f
minor changes before mergin again
wangg131 Jul 30, 2015
c1464f8
WIP: carrierwave images.
brittinator Jul 30, 2015
8322cc1
Merging.
brittinator Jul 30, 2015
016a48c
Merge pull request #4 from brittinator/carrierwave
brittinator Jul 30, 2015
c10a2ce
recipes controller spec
wangg131 Jul 30, 2015
a53f572
WIP: remove recipe association from cookbook.
brittinator Jul 30, 2015
091ce77
WIP: deleting association between recipe and cookbook.
brittinator Jul 30, 2015
32708f3
recipe controller specs cont...
wangg131 Jul 30, 2015
ce8dec0
Adds when click delete button on cookbook page, delete relationship o…
brittinator Jul 30, 2015
c34fae3
Show cookbookpage.
brittinator Jul 30, 2015
d024f1b
Merge branch 'cookbook-recipe-removal' into blw+lw/master
brittinator Jul 30, 2015
d0fd0d4
rspec test for removing cookbook and recipe relation.
brittinator Jul 30, 2015
6b998e0
WIP: new/edit form for cookbook.
brittinator Jul 30, 2015
99da7f5
Adds new/edit cookbook views.
brittinator Jul 30, 2015
c64c405
fixed new recipe form
wangg131 Jul 30, 2015
f82bc51
recipe controller specs wip
wangg131 Jul 30, 2015
0fbdd4f
Adds specs for new and create Cookbook using factory girl for params.
brittinator Jul 30, 2015
6b8d5d3
WIP: cookbook rspec.
brittinator Jul 30, 2015
d9b4e48
unique ingredients per cookbook
wangg131 Jul 31, 2015
a0402a8
cant edit others' cookbooks
wangg131 Jul 31, 2015
08889fd
destroying a recipe
wangg131 Jul 31, 2015
4a4d714
Default image.
brittinator Jul 31, 2015
11df1ac
Adds default image, recipe seeds have image.
brittinator Jul 31, 2015
be39f5f
add recipe to your cookbook
wangg131 Jul 31, 2015
6afaed7
WIP
brittinator Jul 31, 2015
74a3944
add recipe to cookbook editz
wangg131 Jul 31, 2015
e260c33
add recipe to cookbook editz2
wangg131 Jul 31, 2015
9e4d475
mergin
wangg131 Jul 31, 2015
bcefbe7
Cleanup.
brittinator Jul 31, 2015
70cfad0
Merge branch 'blw+lw/master' into trellotasks
brittinator Jul 31, 2015
46b0563
Grid system for home page.
brittinator Jul 31, 2015
832a57a
factory commented out uniq-ingredient, deleted extra destroy action i…
brittinator Jul 31, 2015
d67060c
user access
wangg131 Jul 31, 2015
68ccdc9
add ingredient
wangg131 Jul 31, 2015
797e6fb
Merge branch '7/30' into blw+lw/master
wangg131 Jul 31, 2015
ffff57b
ingredient user association
wangg131 Jul 31, 2015
71f07b0
working recipe#create test
wangg131 Jul 31, 2015
8b661a6
recipe controller specs wip
wangg131 Jul 31, 2015
b2c56d9
Adds cookbook rspec for delete#destroy action.
brittinator Jul 31, 2015
66ee970
Adds rspec tests for cookbook controller. 97.35% coverage.
brittinator Jul 31, 2015
03712a2
Adds pics to recipe seeds.
brittinator Jul 31, 2015
5bbe571
WIP: styling.
brittinator Jul 31, 2015
895bb60
user controller specs
wangg131 Jul 31, 2015
6922080
megin
wangg131 Jul 31, 2015
255dc40
Merge branch 'blw+lw/master' into 7/30
wangg131 Jul 31, 2015
154bdbc
fixin ingredients controller spec
wangg131 Jul 31, 2015
2345276
Merge pull request #5 from brittinator/7/30
wangg131 Jul 31, 2015
1f5e816
Seeds
brittinator Jul 31, 2015
18b1ce3
Merge branch 'blw+lw/master' of github.com:brittinator/C3Projects--Ad…
brittinator Jul 31, 2015
d7a6676
Updated remove_recipe rspecs to reflect need to have an ingredient in…
brittinator Jul 31, 2015
a35c68c
Seeds
brittinator Jul 31, 2015
0f178d6
fixed ingredient#destroy test
wangg131 Jul 31, 2015
770ce27
working ingredient edit
wangg131 Jul 31, 2015
d9fa16c
Search results page. Flash messages.
brittinator Jul 31, 2015
497df4c
Adds image to search result page.
brittinator Jul 31, 2015
76f0164
recipe#destroy and other recipe controller tests
wangg131 Jul 31, 2015
5588f55
Adds some pizazz style to the recipe index page.
brittinator Jul 31, 2015
a50502d
recipe controllers spec up to 80%
wangg131 Jul 31, 2015
7f0ab4b
Adds 'button' to add a new ingredient when making a new recipe.
brittinator Jul 31, 2015
91013bc
ingredient controller spec wip
wangg131 Jul 31, 2015
126dcd6
Merge branch 'blw+lw/master' of github.com:brittinator/C3Projects--Ad…
brittinator Jul 31, 2015
26f15f5
ingredient controller specs passing woop woop
wangg131 Jul 31, 2015
a3b0a39
WIP styling.
brittinator Jul 31, 2015
529e96f
Merge branch 'blw+lw/master' of github.com:brittinator/C3Projects--Ad…
brittinator Jul 31, 2015
3ad462b
passing cookbook controller tests
wangg131 Jul 31, 2015
ee1af22
Flash messages for forms.
brittinator Jul 31, 2015
e9f2d61
werkin sessions controller spec
wangg131 Jul 31, 2015
ff775ef
Adds links to pictures.
brittinator Jul 31, 2015
172e3b5
PASSIN SPECS YO
wangg131 Jul 31, 2015
1f38e58
model user spec
wangg131 Jul 31, 2015
f00612b
User view.
brittinator Jul 31, 2015
06f902e
recipe model
wangg131 Jul 31, 2015
a9b9c1c
Merge branch '7/31' into blw+lw/master
wangg131 Jul 31, 2015
1ac3bda
Merge branch 'blw+lw/master' of github.com:brittinator/C3Projects--Ad…
brittinator Jul 31, 2015
0969569
small style changes
wangg131 Jul 31, 2015
d247743
Deleted white space.
brittinator Jul 31, 2015
586d64c
Merge branch 'blw+lw/master' of github.com:brittinator/C3Projects--Ad…
brittinator Jul 31, 2015
f899608
Search is now case-insensitive.
brittinator Jul 31, 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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@
!/log/.keep
/tmp
coverage/
/public/uploads
4 changes: 4 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ gem 'sdoc', '~> 0.4.0', group: :doc
gem 'bcrypt', '~> 3.1.7'
gem 'bootstrap-sass'

# for uploads
gem 'mini_magick'
gem 'carrierwave'

# Use Unicorn as the app server
# gem 'unicorn'

Expand Down
8 changes: 8 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ GEM
builder (3.2.2)
byebug (5.0.0)
columnize (= 0.9.0)
carrierwave (0.10.0)
activemodel (>= 3.2.0)
activesupport (>= 3.2.0)
json (>= 1.7)
mime-types (>= 1.16)
coderay (1.1.0)
coffee-rails (4.1.0)
coffee-script (>= 2.2.0)
Expand Down Expand Up @@ -89,6 +94,7 @@ GEM
mime-types (>= 1.16, < 3)
method_source (0.8.2)
mime-types (2.6.1)
mini_magick (4.2.7)
mini_portile (0.6.2)
minitest (5.7.0)
multi_json (1.11.2)
Expand Down Expand Up @@ -196,10 +202,12 @@ DEPENDENCIES
binding_of_caller
bootstrap-sass
byebug
carrierwave
coffee-rails (~> 4.1.0)
factory_girl_rails (~> 4.0)
jbuilder (~> 2.0)
jquery-rails
mini_magick
pg
pry-rails
rails (= 4.2.3)
Expand Down
Binary file added app/assets/.DS_Store
Binary file not shown.
Binary file added app/assets/images/almond_butter.jpg
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/almonds.jpg
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/black_pepper.jpg
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/bok_choy.jpg
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/bokchoy_pineapple.jpg
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/chicken.jpg
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/choc_ice_cream.jpg
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/cilantro.jpg
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/cocoa-powder.jpg
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/coconut_milk.jpg
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/coconut_oil.jpg
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/default_256.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/fake_reeses.jpg
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/honey.jg.jpg
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/honey.jpg
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/maple_syrup.jpg
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/olive_oil.jpg
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/pineapple.jpg
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/sea_salt.jpg
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/yam.jpg
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/yam_chips.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions app/assets/javascripts/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@
//= require jquery
//= require jquery_ujs
//= require turbolinks
//= require bootstrap-sprockets
//= require_tree .
3 changes: 3 additions & 0 deletions app/assets/javascripts/cookbooks.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/home.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/ingredients.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/recipes.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/sessions.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/users.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/
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

/*
* This is a manifest file that'll be compiled into application.css, which will include all the files
* listed below.
Expand All @@ -13,3 +14,16 @@
*= require_tree .
*= require_self
*/

@import "bootstrap-sprockets";
@import "bootstrap";

$error: #F72B1D; /* red for warining */

.container {
margin-top: 30px
}

.error {
color: $error;
}
3 changes: 3 additions & 0 deletions app/assets/stylesheets/cookbooks.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Place all the styles related to the Cookbooks 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/home.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Place all the styles related to the home 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/ingredients.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Place all the styles related to the ingredients 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/recipes.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Place all the styles related to the recipes 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/sessions.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Place all the styles related to the sessions 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/users.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Place all the styles related to the users controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
9 changes: 9 additions & 0 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,13 @@ class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception
MESSAGES = {not_logged_in: "You must be logged in to view this page!" }

def require_login
redirect_to login_path, flash: {error: MESSAGES[:not_logged_in]} unless session[:user_id]
end

# def user_cookbooks
# redirect_to root_path unless session[:user_id]
# end
end
54 changes: 54 additions & 0 deletions app/controllers/cookbooks_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
class CookbooksController < ApplicationController
before_action :require_login, only: [:show, :edit]
before_action :find_cookbook, only: [:show, :edit, :update, :destroy]

def new
@cookbook = Cookbook.new
end

def create
@cookbook = Cookbook.create(cookbook_params)
@cookbook.user_id = session[:user_id]

if @cookbook.save
redirect_to user_path(session[:user_id])
else
flash[:name] = "Please provide a name for your cookbook."
render 'new'
end
end

def show
session[:cookbook_id] = @cookbook.id
if session[:user_id] != @cookbook.user_id
redirect_to user_path(session[:user_id])
end

end

def edit
@cookbook = Cookbook.find(params[:id])
if session[:user_id] != @cookbook.user_id
redirect_to user_path(session[:user_id])
end
end

def update
@cookbook.update(cookbook_params)
redirect_to user_path(session[:user_id])
end

def destroy
@cookbook.destroy
redirect_to user_path(session[:user_id])
end

private
def find_cookbook
@cookbook = Cookbook.find(params[:id])
end

def cookbook_params
params.require(:cookbook).permit(:name, :description, {:recipe_ids => [] })
end
end
5 changes: 5 additions & 0 deletions app/controllers/home_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class HomeController < ApplicationController
def index
@recipes = Recipe.all
end
end
63 changes: 63 additions & 0 deletions app/controllers/ingredients_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
class IngredientsController < ApplicationController
before_action :find_ingredient, only: [:show, :destroy]
before_action :require_login, only: [:new]

def index
@ingredients = Ingredient.all.alphabet
end

def edit
@ingredient = Ingredient.find(params[:id])
if session[:user_id] != @ingredient.user_id
redirect_to ingredient_path(@ingredient)
end
end

def update
@ingredient = Ingredient.find(params[:id])
@ingredient.update(ingredient_params)

if @ingredient.save
redirect_to user_path(session[:user_id])
else
flash[:name] = "Please provide your ingredient name."
render :edit
end
end

def show
@ingredient = find_ingredient
end

def new
@ingredient = Ingredient.new
end

def create
@ingredient = Ingredient.new(ingredient_params)
@ingredient.user_id = session[:user_id]
if @ingredient.save
redirect_to ingredient_path(@ingredient)
else
flash[:name] = "Please provide your ingredient name."
render :new
end
end

def destroy
@ingredient.destroy

redirect_to user_path(session[:user_id])
end

private

def find_ingredient
@ingredient = Ingredient.find(params[:id])
end

def ingredient_params
params.require(:ingredient).permit(:name, :image)
end

end
96 changes: 96 additions & 0 deletions app/controllers/recipes_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
class RecipesController < ApplicationController
before_action :require_login, only: [:new, :add]

def index
if params[:search]
@recipes = Recipe.search(params[:search])
render :results
else
@recipes = Recipe.all.alphabet
render :index
end
end

def edit
@recipe = Recipe.find(params[:id])
if session[:user_id] != @recipe.user_id
redirect_to recipe_path(@recipe)
end
end

def update
@recipe = Recipe.find(params[:id])
@recipe.update(recipe_params)

if @recipe.save
redirect_to user_path(session[:user_id])
else
render :edit
end

end

def new
@user = User.find(session[:user_id])
@recipe = Recipe.new(user_id: @user.id)
@ingredients = Ingredient.all
@cookbook = Cookbook.where(user_id: @user.id )
end

def show
@recipe = Recipe.find(params[:id])
# @user = User.find(@recipe.user_id).username.capitalize
@user_recipes = User.find(@recipe.user_id).username.capitalize
@your_cookbook = User.find(session[:user_id]).cookbooks if session[:user_id]
end

def add
@user = User.find(session[:user_id])
@recipe = Recipe.find(params[:id])
@cookbook = Cookbook.where(user_id: @user.id)
render :add
end

def create
@recipe = Recipe.new(recipe_params)
@recipe.user_id = session[:user_id]
@recipe.validate

if @recipe.valid?
@ingredient_recipe = (params[:recipe][:ingredient_ids].first).to_i
@recipe.ingredients << Ingredient.find(@ingredient_recipe) unless @ingredient_recipe != 0
# This prevents anything from being saved if the user didn't input any ingredients for a recipe
@recipe.save
redirect_to user_path(session[:user_id])
else
@cookbook = Cookbook.where(user_id: session[:user_id])
@user = User.find(session[:user_id])
@ingredients = Ingredient.all
@recipe = Recipe.new(user_id: @user.id)
render :new
end
end

def remove_recipe
cookbook = Cookbook.find(session[:cookbook_id])
recipe = Recipe.find(params[:recipe_id])

if cookbook
recipe.cookbooks.delete(cookbook)
redirect_to root_path
end
end

def destroy
@recipe = Recipe.find(params[:id])
@recipe.destroy
redirect_to user_path(session[:user_id])
end

private


def recipe_params
params.require(:recipe).permit(:user_id, :recipe_id, :name, :description, :image, :ingredients, :preparation, {:ingredient_ids => [] }, {:cookbook_ids => [] })
end
end
22 changes: 22 additions & 0 deletions app/controllers/sessions_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
class SessionsController < ApplicationController
def new
end

def create
@user = User.find_by_username(params[:session][:username])

if @user && @user.authenticate(params[:session][:password])
session[:user_id] = @user.id
redirect_to user_path(session[:user_id])
else
flash.now[:error] = "Incorrect Username/Password Combination, Please Try Again."
render 'new'
end
end

def destroy
session[:user_id] = nil
redirect_to login_path
end

end
Loading