I am following this tutorial building-a-simple-stream-media-app
When i go to change the list to Struct Not quite sure what i am doing, really new to this. it's not working, keep getting
protocol Enumerable not implemented
My controller
defmodule Blog.PageController do
use Blog.Web, :controller
def index(conn, _params) do
media_dir = "./priv/static/media/"
filetype = [".mp4", ".png"]
{:ok, files} = File.ls(media_dir)
filtered_files = Enum.filter(files, fn(file) -> String.ends_with?(file, [".mp4", ".png"]) end)
struct_files = Enum.map(filtered_files, fn(file) -> %Blog.Media{filename: file} end )
render conn, "index.html", files: struct_files
end
def show(conn, %{"filename" => filename}) do
render conn, "show.html", filename: filename
end
end
Model
defmodule Blog.Media do
@derive {Phoenix.Param, key: :filename}
defstruct [:filename]
end