Qqwy
Phoenix: alias and Model names
I am working on my first Phoenix project.
One thing I do not like right now, is that all models are prefixed with the project name. I can understand that this is nicer from a code-hierarcy perspective (less conflicting module names), but many of my files now look like this:
defmodule MyProject.Foo do
alias MyProject.{Repo, Something, SomethingElse, YetAnotherModel, Bar, Baz, Qux, ...}
end
Is there a better way?
Marked As Solved
wojtekmach
You can see how HexWeb solves it:
Also Liked
Qqwy
One of the things I did not know, and thanks for @wojtekmach for pointing this out to me, is that the web/web.ex is a wonderful file where you can list things that all your models/views/controllers require(/import/use) in a single place.
This makes life already a lot easier. ![]()
dgamidov
As far as I understand, it is Elixir naming convention.
I have a lot of same alias App.{Repo, ..}, too ![]()
Last Post!
boddhisattva
Thank you for your prompt responses @wojtekmach, it was fun to learn these new things today with the Elixir and Phoenix way of doing things ![]()
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #elixirconf-us
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #security
- #hex









