I am trying to add geospatial fields to the phoenix framework with https://github.com/bryanjos/geo package. I want to access through Ecto models so I followed the outlined of adding the line:
Postgrex.Types.define(
MyApp.PostgresTypes,
[Geo.PostGIS.Extension] ++
Ecto.Adapters.Postgres.extensions(),
json: Poison)
as outlined in the readme file. Problem is that it doesn't specify exactly where to add this so I added it to config/dev.exs
I then added the line:
types: MyApp.PostgresTypes
to my dev repo config file config/dev.exs
as specified.
I then get the error that Postgrex.Types.define
and Ecto.Adapters.Postgres.extensions
functions do not exist (as the modules are reportedly unavailable.
I then try to put the following lines in lib/myapp/myapp.ex
as I suspect it has something to do with process intialization.
Postgrex.Types.define(
MyApp.PostgresTypes,
[Geo.PostGIS.Extension] ++
Ecto.Adapters.Postgres.extensions(),
json: Poison)
However when I add more fields do another migrate with mix ecto.migrate, I get an error:
function
Jobflo.PostgresTypes.find/2
is undefined (moduleJobflo.PostgresTypes
is not available.
I don't think it should be this hard and suspect I am making an obvious mistake. Anyone familiar with setting up Geo stuff with Phoenix would be greatly appreciated. Thankyou.