Show Menu
Cheatography

Elixir functions Cheat Sheet (DRAFT) by

Elixir functions: - Anonymous Functions

This is a draft cheat sheet. It is a work in progress and is not finished yet.

Phoenix Framework Cheat Sheet

1. Create a New Phoenix Project

mix phx.new task_master --no-live --no-html

2. Configure the Database

config :task_master, TaskMaster.Repo,
  username: "postgres",
  password: "postgres",
  database: "task_master_dev",
  hostname: "localhost",
  pool_size: 10
Edit config­/de­v.exs

3. Generate Task Schema

mix phx.gen.schema Task tasks title:string description:text

4. Migrate Database

mix ecto.migrate

5. Implement Task Context Functions

Create file lib/ta­sk_­mas­ter­/ta­sk.ex:
Define schema "­tas­ks"
Add fields: title, descri­ption
Create changeset function
Implement CRUD functions: list, create, update, delete
 

6. Implement Task Controller Functions

Create file lib/ta­sk_­mas­ter­_we­b/c­ont­rol­ler­s/t­ask­_co­ntr­oll­er.ex:
Use TaskMa­ste­rWeb, :contr­oller
Alias TaskMa­ste­r.Task
Define controller actions: index, create, show, update, delete

7. Test the Applic­ation

Use Postman or curl to test API endpoints:
GET /tasks (list tasks)
POST /tasks (create task)
GET /tasks/:id (view task)
PUT /tasks/:id (update task)
DELETE /tasks/:id (delete task)