Where should I define helper method in Phoenix project?
I want to define helper method like Rails. But I am wondering where should I define helper method.
the method is used in template, view, model and controller. I defined the methods in model like following and import in web.ex. Is it right? Or should I define these in views?
# web/models/session.ex defmodule UserAuthenticator.Session do alias UserAuthenticator.User @doc """ return current user logged in """ def current_user(conn) do id = Plug.Conn.get_session(conn, :current_user) if id, do: UserAuthenticator.Repo.get(User, id) end @doc """ check whether user login in """ def logged_in?(conn) do !!current_user(conn) end end