Last active
November 16, 2015 16:18
Revisions
-
Henry revised this gist
Nov 16, 2015 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -13,6 +13,7 @@ def create def update recipe = Recipe.find(params[:id]) @recipe_form = RecipeForm.new(recipe) if @recipe_form.update redirect_to recipes_path else -
Henry revised this gist
Nov 16, 2015 . 1 changed file with 5 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -13,6 +13,11 @@ def create def update recipe = Recipe.find(params[:id]) @recipe_form = RecipeForm.new(recipe) if @recipe_form.update redirect_to recipes_path else render :edit end end private -
Henry revised this gist
Nov 16, 2015 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -2,6 +2,7 @@ class RecipesController < ApplicationController def create @recipe_form = RecipeForm.new(Recipe.new) @recipe_form.assign_attributes(recipe_params) if @recipe_form.save redirect_to recipes_path else -
Henry revised this gist
Nov 16, 2015 . 1 changed file with 12 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,8 +1,17 @@ class RecipesController < ApplicationController def create @recipe_form = RecipeForm.new(Recipe.new) @recipe_form.assign_attributes(recipe_params) if @recipe_form.save redirect_to recipes_path else render :new end end def update recipe = Recipe.find(params[:id]) @recipe_form = RecipeForm.new(recipe) end private -
Henry revised this gist
Nov 16, 2015 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -10,7 +10,7 @@ def initialize(recipe) def assign_attributes(attributes) attributes.each do |k,v| send("#{attribute}=", v) end end -
Henry renamed this gist
Nov 16, 2015 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
Henry revised this gist
Nov 13, 2015 . 1 changed file with 0 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1 +0,0 @@ -
Henry revised this gist
Nov 13, 2015 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1 @@ test -
Henry revised this gist
Nov 11, 2015 . 2 changed files with 30 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,24 @@ class RecipeForm ATTRIBUTES = [:name, :cooking_time_minutes] attr_reader :recipe attr_accessor *ATTRIBUTES def initialize(recipe) @recipe = recipe end def assign_attributes(attributes) attributes.each do |k,v| public_send("#{attribute}=", v) end end def save ATTRIBUTES.each do |attribute| recipe.public_send("#{attribute}=", send(attribute)) end recipe.save end end This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,13 @@ class RecipesController < ApplicationController def create recipe_form = RecipeForm.new(Recipe.new) recipe_form.assign_attributes(recipe_params) recipe_form.save end private def recipe_params params.require(:recipe).permit(:name, :cooking_time_minutes) end end -
Henry revised this gist
Nov 11, 2015 . 1 changed file with 5 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,2 +1,7 @@ class RecipeForm attr_reader :recipe def initialize(recipe) @recipe = recipe end end -
Henry created this gist
Nov 11, 2015 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,2 @@ class RecipeForm end