From 371079208b600b3c68a512aae96df85e96a32895 Mon Sep 17 00:00:00 2001 From: Josh Atwell Date: Mon, 5 Jun 2017 06:28:53 +0000 Subject: [PATCH] adding devise filters to controllers --- app/controllers/feeds_controller.rb | 2 +- app/controllers/ingredients_controller.rb | 3 +- app/controllers/pages_controller.rb | 2 +- app/controllers/preptimes_controller.rb | 2 +- app/controllers/reviews_controller.rb | 74 ----------------------- app/helpers/exercises_helper.rb | 2 +- 6 files changed, 6 insertions(+), 79 deletions(-) delete mode 100644 app/controllers/reviews_controller.rb diff --git a/app/controllers/feeds_controller.rb b/app/controllers/feeds_controller.rb index adbbe53..96415cb 100644 --- a/app/controllers/feeds_controller.rb +++ b/app/controllers/feeds_controller.rb @@ -1,5 +1,5 @@ class FeedsController < ApplicationController - + before_action :authenticate_user! def new @feed = Feed.new end diff --git a/app/controllers/ingredients_controller.rb b/app/controllers/ingredients_controller.rb index 542fa51..0ad31b1 100644 --- a/app/controllers/ingredients_controller.rb +++ b/app/controllers/ingredients_controller.rb @@ -1,5 +1,6 @@ class IngredientsController < ApplicationController - before_action :require_user, except: [:show] + before_action :authenticate_user!, except: [:show, :index, :like, :search] + before_action :require_user, except: [:show] def show @ingredient = Ingredient.find(params[:id]) diff --git a/app/controllers/pages_controller.rb b/app/controllers/pages_controller.rb index 45f7927..41caeae 100644 --- a/app/controllers/pages_controller.rb +++ b/app/controllers/pages_controller.rb @@ -2,7 +2,7 @@ class PagesController < ApplicationController def home redirect_to recipes_path if logged_in? - + #not sure if this is what we want anymore in-terms of user experience - Josh end end \ No newline at end of file diff --git a/app/controllers/preptimes_controller.rb b/app/controllers/preptimes_controller.rb index 90d15ea..cb33754 100644 --- a/app/controllers/preptimes_controller.rb +++ b/app/controllers/preptimes_controller.rb @@ -1,5 +1,5 @@ class PreptimesController < ApplicationController - + before_action :authenticate_user! def new @preptime = Preptime.new end diff --git a/app/controllers/reviews_controller.rb b/app/controllers/reviews_controller.rb deleted file mode 100644 index 730f419..0000000 --- a/app/controllers/reviews_controller.rb +++ /dev/null @@ -1,74 +0,0 @@ -class ReviewsController < ApplicationController - before_action :set_review, only: [:show, :edit, :update, :destroy] - - # GET /reviews - # GET /reviews.json - def index - @reviews = Review.all - end - - # GET /reviews/1 - # GET /reviews/1.json - def show - end - - # GET /reviews/new - def new - @review = Review.new - end - - # GET /reviews/1/edit - def edit - end - - # POST /reviews - # POST /reviews.json - def create - @review = Review.new(review_params) - - respond_to do |format| - if @review.save - format.html { redirect_to @review, notice: 'Review was successfully created.' } - format.json { render :show, status: :created, location: @review } - else - format.html { render :new } - format.json { render json: @review.errors, status: :unprocessable_entity } - end - end - end - - # PATCH/PUT /reviews/1 - # PATCH/PUT /reviews/1.json - def update - respond_to do |format| - if @review.update(review_params) - format.html { redirect_to @review, notice: 'Review was successfully updated.' } - format.json { render :show, status: :ok, location: @review } - else - format.html { render :edit } - format.json { render json: @review.errors, status: :unprocessable_entity } - end - end - end - - # DELETE /reviews/1 - # DELETE /reviews/1.json - def destroy - @review.destroy - respond_to do |format| - format.html { redirect_to reviews_url, notice: 'Review was successfully destroyed.' } - format.json { head :no_content } - end - end - - private - # Use callbacks to share common setup or constraints between actions. - def set_review - @review = Review.find(params[:id]) - end - - # Never trust parameters from the scary internet, only allow the white list through. - def review_params - params.require(:review).permit(:comment) - end -end diff --git a/app/helpers/exercises_helper.rb b/app/helpers/exercises_helper.rb index 477cee3..4a06c68 100644 --- a/app/helpers/exercises_helper.rb +++ b/app/helpers/exercises_helper.rb @@ -1,7 +1,7 @@ module ExercisesHelper def exercise_owner? - owner_check(@exercises.user_id) + owner_check(@exercises) end end \ No newline at end of file