Skip to content

Commit

Permalink
Added channels and controllers to the readme
Browse files Browse the repository at this point in the history
  • Loading branch information
Nick Gartmann committed Jan 12, 2015
1 parent 3ca7ef8 commit 936ed76
Showing 1 changed file with 58 additions and 2 deletions.
60 changes: 58 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,60 @@
Ashes
=====
#Ashes

A code generation tool for the [Phoenix](http://www.phoenixwebframework.com) web framework.

###Controllers
Generatse 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`**

```bash
$ mix ashes.generate controller <controllername>
```

```elixir
# 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.

```bash
$ mix ashes.generate channel <channelname> [events]
```
```elixir
# 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
```elixir
def handle_in("eventname", message, socket) do
{:ok, socket}
end
```

0 comments on commit 936ed76

Please sign in to comment.