Skip to content
forked from x4lldux/ashes

A code generation tool for the Phoenix web framework

Notifications You must be signed in to change notification settings

mutablestate/ashes

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

#Ashes

A code generation tool for the Phoenix web framework.

defp deps do
  [{:ashes, ">= 0.0.3"}]
end

###Controllers Generates a controller with a given name, will also generate a view and create a folder for you to put related .eex templates in. Don't forget to add the controller in routes.ex

$ mix ashes.generate controller <controllername>
# web/router.ex
defmodule MyApp.Router do
  ...
  scope "/", MyApp do
    resources "/my", MyController
  end
end

Will give you the following functions by default:

  • index
  • edit
  • new
  • show
  • create
  • update
  • delete

Options

  • --skip-form - removes the edit and new functions from the controller (likely used for APIs)
  • --skip-view - doesn't create a view module
  • --skip-template- doesn't create a folder for templates

###Channels Generates a channel with the given name. Don't forget to add the channel to your router

$ mix ashes.generate channel <channelname> [events]
# routes.ex
defmodule MyApp.Router do
  ...
  socket "/ws", MyApp do
    channel "my:*", MyChannel
  end
end

Will give you the following functions by default:

  • join(_topic, message, socket)
  • leave(_reason, socket)

If you provide events in the generate command, they will be added to the channel as

def handle_in("eventname", message, socket) do
  {:ok, socket}
end

###Models Generates an Ecto model with the given name and schema. Requires ecto!

$ mix ashes.generate model <modelname> [schema entries]

Schema entries should be of the form name:type with types being defined by ecto.

Options

  • --timestamps - adds ecto timestamps to your schema.

###Migrations Assumes a valid repo module name of MyApp.Repo

Generates an Ecto migration with the given name. Requires ecto

$ mix ashes.generate migration <migrationname>

About

A code generation tool for the Phoenix web framework

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Elixir 100.0%