philomena/lib/philomena_web/controllers/advert_controller.ex
2020-05-27 17:14:22 -04:00

16 lines
341 B
Elixir

defmodule PhilomenaWeb.AdvertController do
use PhilomenaWeb, :controller
alias PhilomenaWeb.AdvertUpdater
alias Philomena.Adverts.Advert
plug :load_resource, model: Advert
def show(conn, _params) do
advert = conn.assigns.advert
AdvertUpdater.cast(:click, advert.id)
redirect(conn, external: advert.link)
end
end