I am trying to get the id of a role so I can add it as an assoc:
Repo.get_by!(Role, name: "account_owner", prefix: subdomain)
When I do this I get an error:
where does not exist in schema
It seems to think the prefix is a field. I am using Ecto 3.0.1 and it lists prefix as an option for the query. Does anyone have any suggestions?
Try this instead,
Repo.get_by!(Role, [name: "account_owner"], prefix: subdomain)
prefix needs to be the third argument to
get_by!/3. The way you have is the same as doing:
Repo.get_by!(Role, [name: "account_owner", prefix: subdomain])
and Ecto thinks prefix is part of your
@sjoconnor thank you … worked as expected.
I had reverted to using
Repo.Query but this is much cleaner.