I have the following action in my Phoenix app controller:
defmodule TattooBackend.Web.API.V1.StudioController do
use TattooBackend.Web, :controller
alias TattooBackend.Repo
alias TattooBackend.Accounts.Account
def index(conn, params) do
studios = Studio
studios = if params["search"] do
Studio.search(studios, params["search"])
end
studios = studios |> Repo.all |> Repo.preload(:address)
render conn, studios: studios
end
end
Is there any way to refactor this code to be more readable?
params
doesn't have"search"
?studios
would becomenil
in that case as far as I can see. - Dogbert