Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Phoenix controllers - singular or plural?

I know Rails has a pretty solid convention for having plural controller names ex: CustomersController. It seems like Elixir wouldn't care because the routing is done differently. Is there an idiomatic way to name controllers in Phoenix?

like image 306
Brandon Joyce Avatar asked Mar 09 '16 03:03

Brandon Joyce


1 Answers

To avoid some of the confusion that exists in Rails caused by where to use singular vs plural, Phoenix decided to go with singular form consistently. This change was made back in Phoenix v0.4.0. Here's the explanation as to why:

Phoenix also does not impose singular and plural naming rules. Rails naming rules can confuse beginners and advanced developers alike: models use singular names, controllers use plural ones, URL helpers mix both, and so on. Phoenix consistently uses singular rules, as any other Elixir code. You may use plural names for your tables and router paths, but those are explicitly written at your system boundaries.

I bolded the most important part for your convenience. If you'd like to see some of the discussion around where these decisions were made, check out this issue on the Phoenix repo.

like image 200
eric dykstra Avatar answered Sep 28 '22 03:09

eric dykstra