Optional upgrade for new brunch features
def deps do
[{:phoenix, "~> 1.1.2"},
...]
end
Plug 0.10.0 moves CSRF tokens from cookies back to sessions. To avoid future bumps on the road, a get_csrf_token/0
function has been added to controllers and imported into views. Update all your csrf token reference code to use the new function. Additionally, form_tag
and link
helpers have been added that will inject the csrf token for you automatically. You should transition to these new functions where possible, ie:
<%= form_tag("/hello", method: :post) %>
... your form stuff. csrf is inject for you
</form>
defmodule Router do | |
use Phoenix.Router, port: 4000 | |
use Plug.Static, mount: "/public" | |
use Plug.EncryptedSession, secret: "203802482048204820" | |
get "pages/:page", PagesController, :show, as: :page | |
get "files/*path", FilesController, :show | |
get "profiles/user-:id", UsersController, :show | |
resources "users", UsersController |
defmodule Example do | |
defmacro __using__(_options) do | |
quote do | |
Module.register_attribute __MODULE__, :attr, accumulate: true, persist: false | |
import unquote(__MODULE__) | |
end | |
end | |
defmacro append(attr) do |
# This worked on 0.10 | |
defmodule Records do | |
defmacro __using__(_) do | |
quote do | |
defrecord A, name: "chris" | |
defrecord B, id: nil, nested: A.new | |
end | |
end |
defrecord User, email: nil | |
defmodule Access.User do | |
def access(record, attr), do: apply(elem(record, 0), attr, [record]) | |
end | |
user = User.new(email: "foo@bar.com") | |
iex> user[:email] | |
"foo@bar.com" |
defmodule ERedis do | |
@name :eredis_connection | |
def start do | |
{:ok, pid} = :eredis.start_link | |
:global.register_name(@name, pid) | |
end | |
def connection do |
# Assuming your partial is named 'list_row' and your model is 'Todo' | |
class Sync.TodoListRow extends Sync.View | |
maxRows: 10 | |
afterInsert: -> | |
$rows = @$el.siblings("tr") | |
$rows.first().remove() if $rows.length > @maxRows | |
# remove any bad refs | |
git remote prune origin | |
# pipe into bash and auto-delete any branches that have been merged into master! | |
git log master --pretty=format:'%d' | grep '^ (origin' | tr -d ' ()' | sed 's/origin\//git push origin :/' |
I've taken the benchmarks from Matthew Rothenberg's phoenix-showdown, updated Phoenix to 0.13.1 and ran the tests on the most powerful machines available at Rackspace.
Framework | Throughput (req/s) | Latency (ms) | Consistency (σ ms) |
---|