
JimmyCarterSon
Seed Data with Elixir
Hello,
I am working on a new application with Elixir, Dish_out. I want to see Data I follow this tutorial with Elixir Casts. However, I am not sure if what I am doing is correct because my seed file does not work.
My Seed File:
alias DishOut.Recipes
Recipes.insert!(
%{title: "Mac N Cheese", ingredients: "Elbow Pasta, Milk, Cheese, Heavy cream", summary: "Bring pasta to a boil for 10 mins, drain water, add milk, cream, and cheese in. Stir and allow to cool before consuming.", date: "032022"}
)
In video the moderator alias another file, what is that file?
Marked As Solved

kokolegorille
There is no insert! function in the Food structure. And Foods should be the module used to create Food struct.
You cannot invent function name, it needs to exists in the file.
@doc """
Creates a food.
## Examples
iex> create_food(%{field: value})
{:ok, %Food{}}
iex> create_food(%{field: bad_value})
{:error, %Ecto.Changeset{}}
"""
def create_food(attrs \\ %{}) do
%Food{}
|> Food.changeset(attrs)
|> Repo.insert()
end
The closest is this one, and should be used like this…
DishOut.Foods.create_food(attrs)
Also Liked

kokolegorille
Looking at the code… there is no module called Recipes.
One is called Foods, but not Recipes.
Hmm? No error message?
You might test this in the console directly.

JimmyCarterSon
Yes, Recipes don’t exist. I thought we were creating a new one to seed the file?
What do I reference my Schema which is “Delish_foods”
so would it alias DishOut.Delish_foods?
sorry I am a beginner this si my first time seeding a file in elixir.

kokolegorille
The github repo You are following looks like a beginner repo too.
The right name should be DishOut.Foods.Food
delish_foods is the name of the table.
PS. I did not watch the screencast, so I don’t know what’s in.
Popular Backend topics










Other popular topics








Latest in Backend
Latest (all)
Categories:
Popular Portals
- /elixir
- /rust
- /wasm
- /ruby
- /erlang
- /phoenix
- /keyboards
- /js
- /rails
- /python
- /security
- /go
- /swift
- /vim
- /clojure
- /java
- /haskell
- /emacs
- /svelte
- /onivim
- /typescript
- /crystal
- /c-plus-plus
- /tailwind
- /kotlin
- /gleam
- /react
- /flutter
- /elm
- /ocaml
- /vscode
- /opensuse
- /ash
- /centos
- /php
- /deepseek
- /zig
- /scala
- /html
- /debian
- /nixos
- /lisp
- /agda
- /textmate
- /sublime-text
- /react-native
- /kubuntu
- /arch-linux
- /revery
- /ubuntu
- /manjaro
- /django
- /spring
- /diversity
- /lua
- /nodejs
- /slackware
- /julia
- /c
- /neovim