{"project":"54348ec95b10711400c6c445","_id":"55833843870ff41900de4846","user":{"_id":"5435b410495d5d0800f3a603","username":"","name":"Lance Halvorsen"},"initVersion":{"_id":"5558c642eb56ae2f00f714fc","version":"0.13.1"},"tags":[],"__v":0,"createdAt":"2015-06-18T21:29:39.133Z","changelog":[],"body":"https://gist.github.com/chrismccord/def6f4dc444b6a8f8d8b\n\n## Endpoint\n`Plug.Static` added an `:only` option which greatly improves performance by skipping disk reads at runtime. Replace your `Plug.Static` lines in `endpoint.ex` with the following configuration:\n\n```elixir\n  plug Plug.Static,\n    at: \"/\", from: :my_app,\n    only: ~w(css images js favicon.ico robots.txt)\n```\n\n## Router / Controller\nThe `destroy` action has been renamed to `delete`, update your controller actions and url builders accordingly.\n\n## Channels\n\n### Update your phoenix.js file\nBefore you forget, be sure to update your vendored `phoenix.js` file with the new version:\n[phoenix.js](https://raw.githubusercontent.com/phoenixframework/phoenix/45e83bd90343be693a4e92492b85b11aec390b92/priv/static/js/phoenix.js)\n\n### Update your `{:error, ...` return signatures\nThe error return signature has been changed from `{:error, socket, reason}` to `{:error, reason, socket}`\n\n### Update your broadcasting\nBroadcasting outside of a channel or without the context of a `socket`, now requires calling broadcast on your Endpoint module:\n\n0.8.x:\n\n```elixir\nPhoenix.Channel.broadcast(\"rooms:123\", \"new:msg\", %{...})\n```\n\n0.9.0:\n```elixir\nMyApp.Endpoint.broadcast(\"rooms:123\", \"new:msg\", %{...})\n```\n\nIt is also recommended to transition all your `broadcast` calls to `broadcast!`. The non-raising API still works, but `broadcast!` is reccomended for most channels so an exception is raised if the PubSub adapter is unable to deliver the message.\n\n```elixir\n      def handle_in(\"new:msg\", %{\"uid\" => uid, \"body\" => body}, socket) do\n        broadcast! socket, \"new:msg\", %{uid: uid, body: body}\n        {:ok, socket}\n      end\n```\n\n\n\n## PubSub\nThe new PubSub system allows third-party pubsub adapters and now includes a Redis adapter for multinode pubsub without distributed Elixir for hosts like Heroku. The PubSub adapter must now be specified in your Endpoint configuration.\n\n### Configuration for existing <= 0.8 PG2 setups\nTo continue to use the PG2 setup (which is still the default), simply add the following child to your `config.exs` file:\n\n```elixir\n      config :my_app, MyApp.Endpiont,\n        ...\n        pubsub: [adapter: Phoenix.PubSub.PG2]\n```\n\n### Configuration for the new Redis adapter\nIf you'd like to use the new redis adapter instead, simply add the following to your `config.exs` file, and update your deps:\n\nWith localhost redis and no auth:\n\n```elixir\n      config :my_app, MyApp.Endpiont,\n        ...\n        pubsub: [adapter: Phoenix.PubSub.Redis]\n```\n\nWith explicit host and auth:\n\n```elixir\n      config :my_app, MyApp.Endpiont,\n        ...\n        pubsub: [adapter: Phoenix.PubSub.Redis,\n                 options: [host: \"182.168.100.1\", port: 1234, password: \"secret\"]\n```\n\n  next, add `:eredis`, and `:poolboy` to your deps:\n\n```elixir\n      defp deps do\n        [{:eredis, github: \"wooga/eredis\"},\n         {:poolboy, \"~> 1.4.2\"},\n        ...]\n      end\n```\n\n  finally, add `:poolboy` to your applications:\n\n```elixir\n      def application do\n        [mod: {MyApp, []},\n         applications: [..., :phoenix, :poolboy],\n         ...]\n      end\n```\n\n\nIf you were ever calling the `Phoenix.PubSub` API directly, you will now need to provide the PubSub adapter's registered server name to all calls. The default pubsub server name when your Endpoint starts the adapter is inflected from the base module name, ie:\n\n```elixir\nPhoenix.PubSub.subscribe(MyApp.PubSub, self, \"foo:bar\")\nPhoenix.PubSub.broadcast(MyApp.PubSub, \"foo:bar\", %{baz: :bang})\n```\n\n## Plug/CSRF\nPlug.CSRFProtection & `:protect_from_forgery` now uses a cookie instead of session and expects a \"_csrf_token\" parameter instead of \"csrf_token\".","slug":"upgrading-from-v080-to-v090","title":"Upgrading from v0.8.0 to v0.9.0"}

Upgrading from v0.8.0 to v0.9.0


https://gist.github.com/chrismccord/def6f4dc444b6a8f8d8b ## Endpoint `Plug.Static` added an `:only` option which greatly improves performance by skipping disk reads at runtime. Replace your `Plug.Static` lines in `endpoint.ex` with the following configuration: ```elixir plug Plug.Static, at: "/", from: :my_app, only: ~w(css images js favicon.ico robots.txt) ``` ## Router / Controller The `destroy` action has been renamed to `delete`, update your controller actions and url builders accordingly. ## Channels ### Update your phoenix.js file Before you forget, be sure to update your vendored `phoenix.js` file with the new version: [phoenix.js](https://raw.githubusercontent.com/phoenixframework/phoenix/45e83bd90343be693a4e92492b85b11aec390b92/priv/static/js/phoenix.js) ### Update your `{:error, ...` return signatures The error return signature has been changed from `{:error, socket, reason}` to `{:error, reason, socket}` ### Update your broadcasting Broadcasting outside of a channel or without the context of a `socket`, now requires calling broadcast on your Endpoint module: 0.8.x: ```elixir Phoenix.Channel.broadcast("rooms:123", "new:msg", %{...}) ``` 0.9.0: ```elixir MyApp.Endpoint.broadcast("rooms:123", "new:msg", %{...}) ``` It is also recommended to transition all your `broadcast` calls to `broadcast!`. The non-raising API still works, but `broadcast!` is reccomended for most channels so an exception is raised if the PubSub adapter is unable to deliver the message. ```elixir def handle_in("new:msg", %{"uid" => uid, "body" => body}, socket) do broadcast! socket, "new:msg", %{uid: uid, body: body} {:ok, socket} end ``` ## PubSub The new PubSub system allows third-party pubsub adapters and now includes a Redis adapter for multinode pubsub without distributed Elixir for hosts like Heroku. The PubSub adapter must now be specified in your Endpoint configuration. ### Configuration for existing <= 0.8 PG2 setups To continue to use the PG2 setup (which is still the default), simply add the following child to your `config.exs` file: ```elixir config :my_app, MyApp.Endpiont, ... pubsub: [adapter: Phoenix.PubSub.PG2] ``` ### Configuration for the new Redis adapter If you'd like to use the new redis adapter instead, simply add the following to your `config.exs` file, and update your deps: With localhost redis and no auth: ```elixir config :my_app, MyApp.Endpiont, ... pubsub: [adapter: Phoenix.PubSub.Redis] ``` With explicit host and auth: ```elixir config :my_app, MyApp.Endpiont, ... pubsub: [adapter: Phoenix.PubSub.Redis, options: [host: "182.168.100.1", port: 1234, password: "secret"] ``` next, add `:eredis`, and `:poolboy` to your deps: ```elixir defp deps do [{:eredis, github: "wooga/eredis"}, {:poolboy, "~> 1.4.2"}, ...] end ``` finally, add `:poolboy` to your applications: ```elixir def application do [mod: {MyApp, []}, applications: [..., :phoenix, :poolboy], ...] end ``` If you were ever calling the `Phoenix.PubSub` API directly, you will now need to provide the PubSub adapter's registered server name to all calls. The default pubsub server name when your Endpoint starts the adapter is inflected from the base module name, ie: ```elixir Phoenix.PubSub.subscribe(MyApp.PubSub, self, "foo:bar") Phoenix.PubSub.broadcast(MyApp.PubSub, "foo:bar", %{baz: :bang}) ``` ## Plug/CSRF Plug.CSRFProtection & `:protect_from_forgery` now uses a cookie instead of session and expects a "_csrf_token" parameter instead of "csrf_token".