Learning Phoenix with the Programming Phoenix Book
Mid way, chose to migrate my app to 1.3. Thus the conventions and file locations are slightly different, but i've been following along real well.
Stuck at trying to create Relationships ( Chapter 6). Trying to insert a video with an associated user. Relationships all setup correctly in respective Schemas
In streaming.ex # a Context
def create_video(attrs \\ %{}) do
%Video{}
|> video_changeset(attrs)
|> Repo.insert()
end
defp video_changeset(%Video{} = video, attrs) do
video
|> cast(attrs, [:url, :title, :description])
|> validate_required([:url, :title, :description])
end
In video_controller.ex
def create(conn, %{"video" => video_params}) do
current_user = conn.assigns.current_user
changeset =
current_user
|> build_assoc(:videos)
|> Streaming.create_video()
#IEx.pry
case changeset do
This gives me an error:
expected params to be a map, got: `:videos`
I can as well refactor the code to follow the example in the Book, but would love to understand what i'm doing wrong here.
Thank You for any assistance.