Qqwy

Qqwy

TypeCheck Core Team

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

Also Liked

Qqwy

Qqwy

TypeCheck Core Team

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. :smiley:

dgamidov

dgamidov

As far as I understand, it is Elixir naming convention.
I have a lot of same alias App.{Repo, ..}, too :slight_smile:

dgamidov

dgamidov

@Qqwy, you can use schemaless queries :wink:

Last Post!

boddhisattva

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 :slight_smile:

Where Next?

Popular in Questions Top

vegabook
I’m brand new to Phoenix and I have stripped one of the demo applications to the bone. I just want to get an svg up on the screen. Here i...
New
dokuzbir
I want to highlight html closing tags when i click a html tag. That works in .html files but doesnt work for html.eex templates. How can...
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
Fl4m3Ph03n1x
About me? ( if you have nothing better to do than reading about some random guy in the internet :stuck_out_tongue: ) Hello all, this is ...
New
9mm
I am constructing a JSON object (map) and I need to conditionally set a field. I’m trying to write proper elixir-way code… and I’m at a l...
New
albydarned
Hello all! I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
New
fayddelight
I tried installing elixir 1.11.2 erlang 23.3.4 via asdf in my zsh shell. Enabled the versions locally and globally. When I list them ...
New

Other popular topics Top

rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list. ...
New
hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
sergio_101
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
AstonJ
Seen any cool LiveView demos, sample apps or examples? Please post them here! :003:
New
sergio
Kind of like when jquery came out, it was super necessary. Existing drag and drop libraries have a bunch of baggage to support old browse...
New
AstonJ
Posting this to see if we can make things easier for people to get into Neovim. If you use Neovim and have a favourite distro please let ...
New

We're in Beta

About us Mission Statement