This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# User can have many Place | |
# Place can have many User | |
# User has a role for a Place he belongs to | |
# 1) ecto schemas | |
schema "accounts_users" do | |
# fields | |
many_to_many :map_places, Place, join_through: UserPlace | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# it also takes care of translating error messages with Gettext | |
defmodule ApiWeb.Middleware.ChangesetErrorFormatter do | |
import ApiWeb.ErrorHelpers | |
def call(%{errors: []} = res, _), do: res | |
def call(%{errors: errors} = res, _) do | |
formatted_errors = format_changeset_error(errors) | |
%{res | errors: formatted_errors} | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ds |