Skip to content

Commit

Permalink
add resource for recipes
Browse files Browse the repository at this point in the history
  • Loading branch information
mykovasyl committed Feb 8, 2023
1 parent e119b69 commit 265e5cc
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 0 deletions.
2 changes: 2 additions & 0 deletions app/controllers/recipes_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
class RecipesController < ApplicationController
end
2 changes: 2 additions & 0 deletions app/models/recipe.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
class Recipe < ApplicationRecord
end
3 changes: 3 additions & 0 deletions app/serializers/recipe_serializer.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class RecipeSerializer < ActiveModel::Serializer
attributes :id, :title, :readyIn, :image, :summary, :instructions, :ingredients, :sourceURL, :liked
end
1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
delete "/logout", to: "sessions#destroy"

resources :users
resources :recipes

get "*path", to: "fallback#index", constraints: ->(req) { !req.xhr? && req.format.html? }

Expand Down
16 changes: 16 additions & 0 deletions db/migrate/20230208222115_create_recipes.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
class CreateRecipes < ActiveRecord::Migration[7.0]
def change
create_table :recipes do |t|
t.string :title
t.integer :readyIn
t.string :image
t.string :summary
t.string :instructions
t.text :ingredients
t.string :sourceURL
t.boolean :liked

t.timestamps
end
end
end

0 comments on commit 265e5cc

Please sign in to comment.