def index(conn, params) do
city = get_in(params, ["search", "users_city"])
users = Accounts.list_users()
render(conn, "index.html", users: users)
end
#accounts
def list_users do
User
#|> where([p], p.city == "München")
|> Repo.all()
|> Repo.preload(:credential)
end
This works but sure I want send parameter…
I can’t find recent tut thats why I am asking here…
The complete list should be shown if no filter is applied
Only users from the selected city are shown id select field / Filter applied
(3. the select field should show all cities all times…)
Would be great to get some help.
I have tried something like that with no success:
def find_citiy(query, year) when is_nil(year) or byte_size(year) == 0 do
query
end
def find_city(query, city) do
from user in query,
where: user.city == ^city
end