Skip to content

Instantly share code, notes, and snippets.

@unclebean
Last active March 30, 2018 05:46
Show Gist options
  • Save unclebean/5dfef39faea4d867e145bb5686ed5d58 to your computer and use it in GitHub Desktop.
Save unclebean/5dfef39faea4d867e145bb5686ed5d58 to your computer and use it in GitHub Desktop.
phoenix in practice
{:comeonin, "~> 4.0"}
mix deps.get
|> put_pass_hash()
#### Repo insert
Repo.insert(%User{name: "jose", username: "josevalim", password_hash: "<3<3elixir"})
#### REpo query all
Repo.all(User)
#### preinstallation
mix local.hex
mix archive.install https://github.com/phoenixframework/archives/raw/master/phx_new.ez
apt-get install nodejs-legacy // install nodejs
apt-get install inotify-tools // live code reload
sudo -u postgres createuser <username>
sudo -u postgres createdb <dbname>
sudo -u postgres psql
ALTER USER user_name WITH PASSWORD 'new_password';
ALTER USER username CREATEDB;
grant all privileges on database <dbname> to <username> ;
#### create project
mix phoenix.new rumbl
#### start server
mix phoenix.server
#### init repo
mix ecto.create
#### create migration file
mix ecto.gen.migration create_user
#### migrate database
mix ecto.migrate
#### show all routes
mix phx.routes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment