-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
35 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,31 @@ | ||
class SaverRecipesController < ApplicationController | ||
|
||
# def new | ||
# @recipe_ingredient = RecipeIngredient.new(params) | ||
# @recipe_ingredient.save | ||
# end | ||
# | ||
def new | ||
@saver_recipe = SaverRecipe.new | ||
end | ||
|
||
|
||
def create | ||
@recipe = Recipe.find_by(id: params[:saver_recipe][:saved_recipe_id]) | ||
@saver_recipe = SaverRecipe.create(saver_id: params[:saver_recipe][:saver_id], saved_recipe_id: params[:saver_recipe][:saved_recipe_id]) | ||
redirect_to recipe_path(@recipe) | ||
flash[:notice] = "Successfully saved #{@recipe.author.name}'s recipe #{@recipe.name} to your favorite recipes list" | ||
end | ||
|
||
|
||
# def create | ||
# @saver_recipe = SaverRecipe.new(saver_recipe_params) | ||
# end | ||
def destroy | ||
@saver_recipe = SaverRecipe.find(params[:id]) | ||
@recipe = Recipe.find_by_id(@saver_recipe.saved_recipe_id) | ||
@saver_recipe.destroy | ||
redirect_to recipe_path(@recipe) | ||
flash[:notice] = "Successfully removed #{@recipe.author.name}'s recipe #{@recipe.name} from your favorite recipes list" | ||
end | ||
|
||
|
||
|
||
private | ||
def sacver_recipe_params | ||
params.require(:recipe).permit(:saver_id, :saved_recipe_id) | ||
def saver_recipe_params | ||
params.require(:saver_recipe).permit(:saver_id, :saved_recipe_id) | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters