elixir-phoenix.md
#Repository
- An API for holding things
#Notes
-
Phoenix uses singular names throughout
-
Ecto also has a feature called changesets that holds all changes you want to perform on the database. It encapsulates the whole process of receiving external data, casting and validating it before writing it to the database.
-
mix phoenix.new
-
mix ecto.create
-
mix phoenix.server (or iex -S mix phoenix.server)
-
Views are like rails helpers
-
Controller names should be singular (user_controller.ex vs users_controller.ex)
-
.ex is simular to .rb, .eex is similar to .erb.
-
Changesets - holds all changes you want to perform on the database. It encapsulates the whole process of receiving external data, casting and validating it before writing it to the database. Changesets let Ecto manage record changes, cast parameters, and perform validations.
-
Repo.insert(%User{first_name: "Adam", last_name: "Rubin", password_hash: "foo"})
-
Repo.all(User)
-
Repo.get(User, 1)