{"__v":0,"_id":"55c2e255ff75870d00129ec7","initVersion":{"_id":"55b6448f6127b12500364357","version":"0.15.0"},"project":"54348ec95b10711400c6c445","tags":[],"user":{"_id":"5435b410495d5d0800f3a603","username":"","name":"Lance Halvorsen"},"createdAt":"2015-08-06T04:28:05.877Z","changelog":[],"body":"## Phoenix dep\n\nUpdate your phoenix dep:\n\n```elixir\ndef deps do\n [...,\n  {:phoenix, \"~> 0.16\"},\n  ...]\nend\n```\n\nThen run `mix deps.update phoenix`\n\n## Router, secure browser headers\nWe have enhanced security by setting secure browser headers. Add it to the bottom of your `:browser` pipeline:\n\n```elixir\n  pipeline :browser do\n    ...\n    plug :put_secure_browser_headers\n  end\n```\n\n## Controllers\n- `controller_template/1` has been renamed to `view_template/1`\n- `jsonp/3` function has been removed in favor of the `plug :allow_jsonp`\n\n## Views\n\n`render_one` and `render_many` no longer inflect the view module from the model in favor of explicitly passing the view\n\n0.15.x:\n```elixir\nrender_one user, \"show.html\"\n```\n\n0.16.0:\n```elixir\nrender_one user, UserView, \"show.html\"\n```\n\n## Channels\n\n### transport `:origins` options has been renamed to `:check_origin:`\nIf you are using this option, just rename `origins:` to `check_origin:`. If you don't know what this option is, simply ignore :)\n\n### phoenix.js channels client\n\n`socket.chan` has been renamed to `socket.channel`:\n\n\n0.15.x:\n```javascript\nlet channel = socket.chan(\"rooms:123\")\n```\n\n0.16.0:\n```javascript\nlet channel = socket.channel(\"rooms:123\")\n```\n\nSocket params have moved from the `Socket` constructor to the `connect` funnction:\n\n0.15.x:\n```javascript\nlet socket = new Socket(\"/socket\", {params: {userToken: token})\nsocket.connect()\n```\n\n0.16.0:\n```javascript\nlet socket = new Socket(\"/socket\")\nsocket.connect({userToken: token})\n```\n\n*Note*: Socket params are no longer merged as default params for channel params. Use connect/2 on the server to wire up default channel assigns.\n\nNext, Replace your `web/static/vendor/phoenix.js` with the new client https://raw.githubusercontent.com/phoenixframework/phoenix/38c0d328be429fb8eda3ab428478b78d3ecef002/priv/static/phoenix.js\n**OR** move to the optional update to pull phoenix.js direclty from your phoenix dep (below):\n\n## Update brunch-config.js to pull phoenix.js and phoenix_html.js from phoenix deps (Optional)\nNew applications pull phoenix.js and phoenix_html.js direclty from your local phoenix dep, allowing you to get upgrades whenever they come.\nTo enable this change in your app, delete your `web/static/vendor/phoenix.js` file and update your brunch config:\n\n`brunch-config.js`, update your `paths:` config to include phoenix deps:\n```javascript\n  paths: {\n    // Dependencies and current project directories to watch\n    watched: [\"deps/phoenix/web/static\",\n              \"deps/phoenix_html/web/static\",\n              \"web/static\", \"test/static\"],\n\n    // Where to compile files to\n    public: \"priv/static\"\n  },\n```\n\nThen import the channels client and phoenix_html into your `web/static/js/app.js`:\n\n```javascript\nimport {Socket} from \"deps/phoenix/web/static/js/phoenix\"\nimport \"deps/phoenix_html/web/static/js/phoenix_html\"\n```\n\nUpdate your `:phoenix_html` dep to `~> 2.0` in `mix.exs`:\n\n```elixir\ndef deps do\n [...,\n  {:phoenix_html, \"~> 2.0\"},\n  ...]\nend\n```\n\nThen run `mix deps.update phoenix_html` and restart your server to rebuild your app.js bundle.\n\n## If not using brunch (or you skipped the above step), vendor phoenix_html.js is your asset building pipeline\nWe no longer use obtrusive javascript in the phoenix_html project to handle our `link .., method: ` click events. For brunch users, this is taken care of by the above step. For everyone else, vendor https://raw.githubusercontent.com/phoenixframework/phoenix_html/bc208c5437bbf0177ebe6770cc55e5e31ba04e22/priv/static/phoenix_html.js in your asset builder.\n\n\n\n\n## Use brunch's new autoRequire feature (optional):\n\nBrunch has a new `autoRequire` feature allowing you to ditch the `<script>require(\"web/static/js/app\")</script>` in your layout, which bootstraps your js app. \nTo use the new feature, first remote the above line from your `web/templates/layout/app.html.eex`, then upgrade your npm brunch dependency in `package.json`:\n\n```javascript\n  \"dependencies\": {\n    \"brunch\": \"^1.8.5\",\n    ...\n  }\n```\n\nThen update your `brunch-config.js` to use the new autoRequire option:\n\n```javascript\n  modules: {\n    autoRequire: {\n      'js/app.js': ['web/static/js/app']\n    }\n  },\n```\n\nNext, update your bruch watcher config in `config/dev.exs` to pass the newly required --stdin flag:\n\n```elixir\nwatchers: [node: [\"node_modules/brunch/bin/brunch\", \"watch\", \"--stdin\"]]\n```\n\nLastly run `$ npm install` to pull down the new brunch and restart your server to rebuild your app.js bundle.\n\n## Phoenix Live Reload\n\nUpdate `:phoenix_live_reload` to the latest versioN:\n\n```elixir\ndef deps do\n  [...\n   {:phoenix_live_reload, \"~> 0.6\"},\n  ..]\nend\n```","slug":"upgrading-from-v0150-to-v0160","title":"Upgrading from v0.15.0 to v0.16.0"}

Upgrading from v0.15.0 to v0.16.0


## Phoenix dep Update your phoenix dep: ```elixir def deps do [..., {:phoenix, "~> 0.16"}, ...] end ``` Then run `mix deps.update phoenix` ## Router, secure browser headers We have enhanced security by setting secure browser headers. Add it to the bottom of your `:browser` pipeline: ```elixir pipeline :browser do ... plug :put_secure_browser_headers end ``` ## Controllers - `controller_template/1` has been renamed to `view_template/1` - `jsonp/3` function has been removed in favor of the `plug :allow_jsonp` ## Views `render_one` and `render_many` no longer inflect the view module from the model in favor of explicitly passing the view 0.15.x: ```elixir render_one user, "show.html" ``` 0.16.0: ```elixir render_one user, UserView, "show.html" ``` ## Channels ### transport `:origins` options has been renamed to `:check_origin:` If you are using this option, just rename `origins:` to `check_origin:`. If you don't know what this option is, simply ignore :) ### phoenix.js channels client `socket.chan` has been renamed to `socket.channel`: 0.15.x: ```javascript let channel = socket.chan("rooms:123") ``` 0.16.0: ```javascript let channel = socket.channel("rooms:123") ``` Socket params have moved from the `Socket` constructor to the `connect` funnction: 0.15.x: ```javascript let socket = new Socket("/socket", {params: {userToken: token}) socket.connect() ``` 0.16.0: ```javascript let socket = new Socket("/socket") socket.connect({userToken: token}) ``` *Note*: Socket params are no longer merged as default params for channel params. Use connect/2 on the server to wire up default channel assigns. Next, Replace your `web/static/vendor/phoenix.js` with the new client https://raw.githubusercontent.com/phoenixframework/phoenix/38c0d328be429fb8eda3ab428478b78d3ecef002/priv/static/phoenix.js **OR** move to the optional update to pull phoenix.js direclty from your phoenix dep (below): ## Update brunch-config.js to pull phoenix.js and phoenix_html.js from phoenix deps (Optional) New applications pull phoenix.js and phoenix_html.js direclty from your local phoenix dep, allowing you to get upgrades whenever they come. To enable this change in your app, delete your `web/static/vendor/phoenix.js` file and update your brunch config: `brunch-config.js`, update your `paths:` config to include phoenix deps: ```javascript paths: { // Dependencies and current project directories to watch watched: ["deps/phoenix/web/static", "deps/phoenix_html/web/static", "web/static", "test/static"], // Where to compile files to public: "priv/static" }, ``` Then import the channels client and phoenix_html into your `web/static/js/app.js`: ```javascript import {Socket} from "deps/phoenix/web/static/js/phoenix" import "deps/phoenix_html/web/static/js/phoenix_html" ``` Update your `:phoenix_html` dep to `~> 2.0` in `mix.exs`: ```elixir def deps do [..., {:phoenix_html, "~> 2.0"}, ...] end ``` Then run `mix deps.update phoenix_html` and restart your server to rebuild your app.js bundle. ## If not using brunch (or you skipped the above step), vendor phoenix_html.js is your asset building pipeline We no longer use obtrusive javascript in the phoenix_html project to handle our `link .., method: ` click events. For brunch users, this is taken care of by the above step. For everyone else, vendor https://raw.githubusercontent.com/phoenixframework/phoenix_html/bc208c5437bbf0177ebe6770cc55e5e31ba04e22/priv/static/phoenix_html.js in your asset builder. ## Use brunch's new autoRequire feature (optional): Brunch has a new `autoRequire` feature allowing you to ditch the `<script>require("web/static/js/app")</script>` in your layout, which bootstraps your js app. To use the new feature, first remote the above line from your `web/templates/layout/app.html.eex`, then upgrade your npm brunch dependency in `package.json`: ```javascript "dependencies": { "brunch": "^1.8.5", ... } ``` Then update your `brunch-config.js` to use the new autoRequire option: ```javascript modules: { autoRequire: { 'js/app.js': ['web/static/js/app'] } }, ``` Next, update your bruch watcher config in `config/dev.exs` to pass the newly required --stdin flag: ```elixir watchers: [node: ["node_modules/brunch/bin/brunch", "watch", "--stdin"]] ``` Lastly run `$ npm install` to pull down the new brunch and restart your server to rebuild your app.js bundle. ## Phoenix Live Reload Update `:phoenix_live_reload` to the latest versioN: ```elixir def deps do [... {:phoenix_live_reload, "~> 0.6"}, ..] end ```