Skip to content

Instantly share code, notes, and snippets.

chrismccord / gist:be5c3cf8f89b252122ba
Last active Jan 2, 2018
Phoenix (Sass/CoffeeScript)
View gist:be5c3cf8f89b252122ba
# Gulpfile.js
# // Note the new way of requesting CoffeeScript since 1.7.x
# require('coffee-script/register');
# // This bootstraps your Gulp's main file
# require('./');
# assets
# ├──
# ├── Gulpfile.js
View dynamic_dispatch.ex
# in your app supervisor
:phx_dyn_dispatch =, [:named_table, :bag, :public])
defmodule DynamicDispatch do
def register(group, plug, opts) do
true = :ets.insert(:phx_dyn_dispatch, {group, plug, opts})
def unregister(group, plug) do
chrismccord /
Created Oct 6, 2015 — forked from eoinkelly/
Upgrade Postgres to 9.4 using Homebrew on Mac OSX
# This script can be used in "run & hope" mode or you can use it as a recipe to
# do things manually - you probably want the latter if you really care about
# the data in your databases.
# Happy hacking
# /Eoin/
# Tell bash to stop if something goes wrong
set -e
chrismccord / gist:6298006
Last active Jan 8, 2017
Rails callback/listener approach to shared service object behavior from controllers
View gist:6298006
class CommentsController < ApplicationController
def create, params[:comment], self).create
def create_successful(comment)
chrismccord / gist:c24b2b516066d987f4fe
Last active Apr 24, 2016
Phoenix 0.6.x to 0.7.0 Upgrade Instructions
View gist:c24b2b516066d987f4fe

How to upgrade to Phoenix from 0.6.x to 0.7.0.

  1. 0.7.0 depends on Plug HEAD, so you'll need to include plug in your mix deps until the next plug release:
{:plug, github: "elixir-lang/plug", ref: "7040c89cb4cf1f1c6afdee379e5982a07d77a6c3"}

  1. The `Pheonix.Controller` functions html/2, json/2, text/2, redirect/2 and render/3 no longer halt automatically. *Important*: You must now explicity call `halt/1` yourself if you want to stop invoking further plugs after calling these functions. This is improtant for auth filtering plugs, ie:

chrismccord / gist:b3975ba356dba902ec88
Last active Feb 12, 2016
Phoenix Upgrade Instructions 0.11.x 0.12.0
View gist:b3975ba356dba902ec88

Build-embedded and start permanent

Elixir v1.0.4 ships with two new important options for new projects. For projects generated prior to Elixir 1.0.4, add these options to your project entries in mix.exs:

build_embedded: Mix.env == :prod,
start_permanent: Mix.env == :prod

Asset Digests (optional)

A new phoenix.digest task is now inluded which digests and compress static files and can be used during deploy. It also integrates with the static_path helper to render the proper asset paths from the manifest.

chrismccord / gist:3603fd2735019f86c74b
Last active Feb 12, 2016
Phoenix 0.10 to 0.11.0 upgrade instructions
View gist:3603fd2735019f86c74b


Add these functions to the bottom of mix.exs:

  # Specifies which paths to compile per environment
  defp elixirc_paths(:test), do: ["lib", "web", "test/support"]
  defp elixirc_paths(_),     do: ["lib", "web"]
chrismccord / gist:0a3bf5229801d61f219b
Last active Feb 12, 2016
Phoenix Upgrade Instructions 0.12.x 0.13.0
View gist:0a3bf5229801d61f219b


First, clean your deps to avoid phoenix_html conflicts:

$ mix deps.clean phoenix --all

Next, bump phoenix:

{:phoenix, "~> 0.13"},
chrismccord / gist:57805158f463d3369103
Last active Feb 12, 2016
Phoenix Upgrade Instructions 0.13.x 0.14.0
View gist:57805158f463d3369103

First, bump your phoenix in mix.exs:

def deps do
  [{:phoenix, "~> 0.14"}, ...


Update your phoenix_html version to 1.1.0 in mix.exs:

chrismccord /
Last active Jan 28, 2016
Phoenix 1.1.1 to 1.1.2 upgrade instructions

Phoenix 1.1.1 to 1.1.2 upgrade instructions

Optional upgrade for new brunch features

Update your phoenix deps

def deps do
  [{:phoenix, "~> 1.1.2"},