-
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
20 changed files
with
224 additions
and
79 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
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 |
---|---|---|
@@ -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 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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
// Place all the styles related to the SaverRecipe controller here. | ||
// They will automatically be included in application.css. | ||
// You can use Sass (SCSS) here: http://sass-lang.com/ |
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
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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
class SaverRecipesController < ApplicationController | ||
|
||
# def new | ||
# @recipe_ingredient = RecipeIngredient.new(params) | ||
# @recipe_ingredient.save | ||
# end | ||
# | ||
|
||
# def create | ||
# @saver_recipe = SaverRecipe.new(saver_recipe_params) | ||
# end | ||
|
||
|
||
|
||
private | ||
def sacver_recipe_params | ||
params.require(: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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
module SaverRecipeHelper | ||
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
10 changes: 10 additions & 0 deletions
10
app/views/recipe_ingredients/_recipe_ingredient_form.html.erb
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<%= form_for(@recipe_ingredient) do |t| %> | ||
<%= t.hidden_field :recipe_id, :value => params[:recipe_id] %><br> | ||
<%= t.collection_select :ingredient_id, Ingredient.all, :id, :name, { prompt: "Choose an ingredient" }%><br> | ||
|
||
|
||
<%= t.number_field :quantity, placeholder: 'Quantity' %> | ||
<%= t.select :units, ['Cup(s)', 'Gram(s)', 'Kilogram(s)', 'Liter(s)', 'Mililiter(s)', 'Pound(s)', 'Ounce(s)', 'Pint(s)', 'Teaspoon(s)', 'Tablespoon(s)'], { prompt: "Choose a unit of measure" }%><br><br> | ||
|
||
<%= t.submit "Add Ingredient to Recipe " %> | ||
<% 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,3 @@ | ||
<h1> New Recipe Ingredient </h1> | ||
|
||
<%= form_for(@recipe_ingredient) do |t| %> | ||
|
||
|
||
<%= t.hidden_field :recipe_id, :value => params[:recipe_id] %><br> | ||
<%= t.collection_select :ingredient_id, Ingredient.order(:name), :id, :name, include_blank: false%><br> | ||
<%= t.number_field :quantity, placeholder: 'Quantity' %> | ||
|
||
<%= t.submit "Create Recipe-Ingredient" %> | ||
<% end %> | ||
<%= render "recipe_ingredient_form" %> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<h1>Edit <%@recipe.name%></h1> | ||
|
||
<%= render 'recipe_form' %> |
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,21 +1,63 @@ | ||
<h1><%= @recipe.name %></h1> | ||
<h3>made by <%= @author.name %></h3> | ||
|
||
<p>prep time: <%= @recipe.prep_time %> minutes</p><br> | ||
<p>cook time: <%= @recipe.cook_time %> minutes</p><br> | ||
<p><strong>Total Time: <%= "#{@recipe.prep_time + @recipe.cook_time}" %></strong></p><br> | ||
|
||
<p> | ||
<strong>Instructions: </strong> | ||
<%= @recipe.instructions %> | ||
</p> | ||
|
||
<% if @recipe.ingredients.count > 0 %> | ||
<ul> | ||
<% @recipe.recipe_ingredients.each do |i| %> | ||
<li><%= i.quantity %> - <%= i.ingredient.name %></li> | ||
<% end %> | ||
</ul> | ||
<% end %> | ||
|
||
<%= link_to 'Add Recipe-Ingredient', new_recipe_ingredient_path(:recipe_id => @recipe.id) %> | ||
<h4>made by <%= @author.name %></h4> | ||
|
||
<div> | ||
<% if current_user == @recipe.author%> | ||
<a class="btn" href="<%= edit_recipe_path(@recipe)%>">Edit</a> | ||
<a class="btn" href="<%= edit_recipe_path(@recipe)%>">Delete Recipe</a> | ||
<% else %> | ||
<!-- THIS BUTTON IS NOT YET WORKING WORKING ON IT NOW --> | ||
<%= link_to "Save Recipe", new_saver_recipe_path(saver_id: current_user.id, saved_recipe_id: @recipe.id) %> | ||
<% end %> | ||
</div><br><br> | ||
|
||
<div> | ||
<%= image_tag @recipe.image.url(:medium) if @recipe.image? %> | ||
</div> | ||
|
||
<div> | ||
<h5>Overview </h5> | ||
<p>Prep Time: <%= @recipe.prep_time %> minutes</p> | ||
<p>Cook Time: <%= @recipe.cook_time %> minutes</p> | ||
<p><strong>Total Time: <%= "#{@recipe.prep_time + @recipe.cook_time}" %> minutes</strong></p> | ||
</div> | ||
|
||
|
||
<div> | ||
<h5>Ingredients: </h5> | ||
<% if @recipe.ingredients.count > 0 %> | ||
<ul> | ||
<% @recipe.recipe_ingredients.each do |i| %> | ||
<li><%= i.quantity %> <%= i.units%> — <%= i.ingredient.name %> <%= link_to "Delete", i, method: :delete %></li> | ||
<% end %> | ||
</ul> | ||
<% end %> | ||
<% if current_user == @recipe.author%> | ||
<!-- Modal Trigger --> | ||
<a class="modal-trigger waves-effect waves-light btn" href="#add_recipe_ingredient_modal">Add Ingredient</a> | ||
|
||
<!-- Modal Structure --> | ||
<div id="add_recipe_ingredient_modal" class="modal modal-fixed-footer"> | ||
<div class="modal-content"> | ||
<h4>Add Ingredient to <%=@recipe.name%></h4> | ||
<%= form_for(@recipe_ingredient) do |t| %> | ||
<%= t.hidden_field :recipe_id, value: @recipe.id %><br> | ||
<%= t.collection_select :ingredient_id, Ingredient.all, :id, :name, { prompt: "Choose an ingredient" }%><br> | ||
|
||
<%= t.number_field :quantity, placeholder: 'Quantity' %> | ||
<%= t.select :units, ['Cup(s)', 'Gram(s)', 'Kilogram(s)', 'Liter(s)', 'Mililiter(s)', 'Pound(s)', 'Ounce(s)', 'Pint(s)', 'Teaspoon(s)', 'Tablespoon(s)'], { prompt: "Choose a unit of measure" }%><br><br> | ||
|
||
<%= t.submit "Add Ingredient to Recipe " %> | ||
<% end %> | ||
</div> | ||
</div> | ||
<% end %> | ||
|
||
|
||
</div> | ||
|
||
|
||
<div> | ||
<h5>Instructions: </h5> | ||
<%= simple_format @recipe.instructions %> | ||
</div><br> |
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
Oops, something went wrong.