Skip to content

Commit

Permalink
add description of recipes show action and view pre Rails & JS project
Browse files Browse the repository at this point in the history
  • Loading branch information
sgibson47 committed Nov 13, 2018
1 parent e211e5b commit 04bade2
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions Blog-about-this/Blog_about_this.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,43 @@ When I navigated to my ingredients index page the GET request would fire, all of

<h3> Refactoring the Show Page </h3>

Next, I turned to refactoring the recipes show page. I had rendered the details of a particular recipe by passing an instance variable that represented a recipe to the recies show view and then displaying attributes of the passed in recipe with ERB and a partial that handled iterating through and formatting a recipe's ingredients for display.

My recipes#show controller action looked like this:

before_action :find_recipe_by_params_id, only: [:update, :destroy, :edit, :show]

def show
end

private

def find_recipe_by_params_id
@recipe = Recipe.find(params[:id])
end

And, my recipes show view looked like this:

<div id="recipe-show">
<h1><%=@recipe.name%>'s Page</h1>
<div class="block ingred-list">
<h3>Ingredients:</h3>
<%= render "display_ingredients_for_recipe_show", recipe: @recipe %>
</div><!--ingred-ist-->

<div class="block instructions">
<h3>Instructions</h3>
<p><%=@recipe.instructions%></p>
</div><!--instructions-->
<div class="edit_delete">
<div class="edit block">
<%=link_to "Edit Recipe", edit_recipe_path(@recipe) %>
</div><!--edit-->
<div class="delete block">
<%=link_to "Delete Recipe", recipe_path(@recipe), method: :delete %>
</div><!--delete-->
</div><!--edit_delete-->
</div><!--recipe-show--> </div><!--recipe-show-->



Expand Down

0 comments on commit 04bade2

Please sign in to comment.