Ivanari
Ivanari

Reputation: 313

Unable to generate html in Phoenix 1.3

Trying to generate:

$ mix phx.gen.html MyModel my_models a b c d:integer

And error:

  ** (Mix) Expected the schema, "my_models", 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).

This doesn't work either:

$ mix phx.gen.html MyModel my_models a b c d:integer --no-context

$ mix phx.gen.html MyModel my_models a b c d:integer --no-context --no-schema

And even after this the error remains:

config :my_app, :generators,
    context: false

What's up with it?

Upvotes: 0

Views: 398

Answers (2)

udehben
udehben

Reputation: 11

to make the above answer a bit clearer,

mix phx.gen.html Thebindingcontext MyModel mymodels a b c d:integer

Upvotes: 1

djelic
djelic

Reputation: 141

From the documentation on phx.gen.html:

Generating without a schema or context file

In some cases, you may wish to boostrap HTML templates, controllers, and controller tests, but leave internal implementation of the context or schema to yourself. You can use the --no-context and --no-schema flags for file generation control.

The --no-context flag instructs generator to leave implementation of context module to developer but you still need to include name of context module in command like this:

mix phx.gen.html MyContext MyModel my_models a b c d:integer --no-context

Upvotes: 1

Related Questions