Skip to content

Instantly share code, notes, and snippets.

@adamrubin
Last active November 20, 2015 21:42
Show Gist options
  • Save adamrubin/a9685ad07ecb07e6b5dd to your computer and use it in GitHub Desktop.
Save adamrubin/a9685ad07ecb07e6b5dd to your computer and use it in GitHub Desktop.
elixir phoenix

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment