defmodule Ami.ThumbImage do use Ecto.Schema schema "thumb_images" do field(:name, :string) field(:file, :string) field(:course_id, :integer) end def thumb_image_for_course(struct) do ti = List.last(struct) if ti != nil, do: "https://ami-aws-staging.s3.amazonaws.com/uploads/thumb_image/file/#{ti.id}/#{ti.file}" end end