joaquinalcerro

joaquinalcerro

Phoenix html generator in umbrella app

So I am exploring Umbrella Apps to migrate a old application to have a better separation of concerns and of course I am trying to use the mix phx.gen tasks generators.

I am using Phoenix 1.4 and this version has the :context_app generator configuration options which work perfectly. But I have the following scenario:

apps
|
— db_service
|
— test
|
— test_web

I am trying to use the “test” application to host the context API. And I am trying to use the “db_service” application to use all the ecto stuff like schemas, etc.

So I have two questions:

  1. Should I separate the context from the schemas or
  2. Is there a proper command mix phx.gen.html [options] to do all this operation in one go

It is important to say that I can configure this scenario using the different command: mix phx.gen.html, mix phx.gen.context, mix phx.gen.schema but I still require some manual changes to make this work properly.

Thank you all for your feedback and suggestions.

Best regards,

Most Liked

easco

easco

If I understand what you are trying to accomplish, then I would say “most definitely yes”. The context represents a logical chunk of functionality in your application - something that your application knows how to do. Say your application was for tracking shipments, then your context would be about how do you represent a shipment, what kind of operations can you do on shipments etc.

Your schema sits at the edge of your application and is concerned with how the elements of the context are represented in one particular type of storage (that being stored in a database). It’s a separation of concerns issue; you’re trying to separate what a thing is, from how that thing happens to be stored. If you wanted to get rid of a database and use a flat-file, or hook your application up to a 3D printer that generated plastic slabs where the data is encoded as if chiseled in stone, then you wouldn’t need the schemas - but the main logic of your application, the contexts, should still be valid.

Last Post!

joaquinalcerro

joaquinalcerro

Thanks for your explanation and time.

Best regards.

Where Next?

Popular in Questions Top

baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
New
mcarvalho
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
joeerl
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New
sen
Hi All, I set a environment variables in dev.exs , like below code. when i start server, how can i set the ${enable} value? thanks. d...
New
fireproofsocks
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? Ecto.Repo — Ecto v3.14.0 has exampl...
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New
senggen
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] 15:22:35.803 [error] gen_event {lager_file_backend...
New

Other popular topics Top

JeremM34
Hello, how can I check the Phoenix version ? Thanks !
New
hariharasudhan94
Lets say I have map like this fetching from my database %{"_id" => #BSON.ObjectId<58eb1a7a9ad169198c3dXXXX>, "email" => ...
New
jononomo
For some reason my phoenix channels are working for me in my local dev environment, but as soon as I deploy via Docker, I get a 403 error...
New
gshaw
What is the idiomatic way of matching for not nil in Elixir? E.g., First way: defp halt_if_not_signed_in(conn, signed_in_account) when...
New
gausby
I asked this very same question on twitter and got some interesting feedback, but I thought it would be a good question to ask here as we...
1207 40165 209
New
jason.o
In the code below, if the create action is not set to accept “extra_key” as an input, it errors out with a message shown above. Is there ...
New

We're in Beta

About us Mission Statement