Skip to content

Commit

Permalink
add recipe description and instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
Kyle Zarazan committed Nov 21, 2024
1 parent 982bcdc commit feb454a
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion app/controllers/recipes_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def update
private

def recipe_params
params.require(:recipe).permit(:name, :description, ingredients_attributes: [:id, :food_id, :amount, :unit, :_destroy])
params.require(:recipe).permit(:name, :description, ingredients_attributes: [:id, :food_id, :measurement, :_destroy])

Check failure on line 28 in app/controllers/recipes_controller.rb

View workflow job for this annotation

GitHub Actions / lint

Layout/SpaceInsideArrayLiteralBrackets: Use space inside array brackets.

Check failure on line 28 in app/controllers/recipes_controller.rb

View workflow job for this annotation

GitHub Actions / lint

Layout/SpaceInsideArrayLiteralBrackets: Use space inside array brackets.
end

Check failure on line 30 in app/controllers/recipes_controller.rb

View workflow job for this annotation

GitHub Actions / lint

Layout/EmptyLinesAroundClassBody: Extra empty line detected at class body end.
end
4 changes: 2 additions & 2 deletions app/views/recipes/_recipe.json.jbuilder
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
json.extract! recipe, :id, :name
json.extract! recipe, :id, :name, :description, :instructions, :created_at, :updated_at

json.ingredients recipe.ingredients do |ingredient|
json.extract! ingredient, :id, :food_id, :measurement
json.extract! ingredient, :id, :food_id, :measurement, :created_at, :updated_at
json.food_name ingredient.food.name
end
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
class CreateRecipies < ActiveRecord::Migration[8.0]
class CreateRecipes < ActiveRecord::Migration[8.0]
def change
create_table :recipes do |t|
t.string :name, null: false
t.string :description
t.text :instructions
t.timestamps
end
end
Expand Down
1 change: 0 additions & 1 deletion db/migrate/20241113161611_create_ingredients.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ def change
create_table :ingredients do |t|
t.references :recipe, foreign_key: true, null: false
t.references :food, foreign_key: true, null: false
t.decimal :amount
t.string :measurement
t.timestamps
end
Expand Down
3 changes: 2 additions & 1 deletion db/schema.rb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit feb454a

Please sign in to comment.