Coder Social home page Coder Social logo

ashes's Introduction

#Ashes

A code generation tool for the Phoenix web framework.

defp deps do
  [{:ashes, ">= 0.0.1"}]
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>
# routes.ex
defmodule MyApp.Router do
  resource "/my", MyController
end

Will give you the following methods by default:

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

Options

  • --skip-form - removes the edit and new methods 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.Routes do
  socket "/ws", MyApp do
    channel "my:*", MyChannel
  end
end

Will give you the following methods by default:

  • join(_topic, 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 a created_at and updated_at field to the schema along with some plumbing to keep the fields up to date.

###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>

ashes's People

Contributors

x4lldux avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.