** (Mix) Expected the context, "x", to be a valid module name

Hello!

Having trouble running the phx.gen.html templates. This is the command I’m trying

mix phx.gen.html Shipments shipmentroutes shipmentroute address:string date:string groups_involved:string

with an error message of this

** (Mix) Expected the schema, "shipmentroutes", to be a valid module name

mix phx.gen.html, phx.gen.json and phx.gen.context expect a
context module name, followed by singular and plural names of
the generated resource, ending with any number of attributes.
For example:

    mix phx.gen.html Accounts User users name:string
    mix phx.gen.json Accounts User users name:string
    mix phx.gen.context Accounts User users name:string

The context serves as the API boundary for the given resource.
Multiple resources may belong to a context and a resource may be
split over distinct contexts (such as Accounts.User and Payments.User).

It doesn’t give any reasoning for why it isn’t a valid module name, so I have no idea how to fix this

1 Like

The validation check that triggers that message is here:

It’s expecting a singular name that starts with a leading A-Z.

1 Like

Interesting, I ended up changing the name to make it work but still don’t understand why mine wouldn’t work. It does start with the alphabet and it is a singular name no?

A-Z means a capital letter not just any letter in the alphabet. Elixir module names must always start with a capital letter (unless explicitly prefixing with :)

2 Likes

oh god duh-- thanks