LoginSignup
12
11

More than 5 years have passed since last update.

Phoenix 1.0から1.1へのアップデートガイド

Last updated at Posted at 2015-12-17

本日(12/17)、Phoenix 1.1が正式にリリースされましたので早速使ってみた。

1.1にはgettextを使った国際化対応のサポートや、channelのパフォーマンス改善、Instrumentation hooksの追加などがあるそうな。

前提

既に1.0で動いているPhoenixアプリケーションを1.1にアップデートすることが前提。

注意点

基本的にmix.exsへの変更が中心だが、1.1での後方互換の無い変更として、以下がアナウンスされているため、そこだけコードをいじる。

  • Backward incompatible changes
    • [View] The @inner assign has been removed in favor of explicit rendering with render/3and the new @view_module and view_template assigns, for example: <%= @inner %> is replaced by <%= render @view_module, @view_template, assigns %>

layoutなどで使っていた<%= @inner %><%= render @view_module, @view_template, assigns %>にしろ、とのこと。

手順

Phoenix本体のアップデート

$ mix archive.install https://github.com/phoenixframework/phoenix/releases/download/v1.1.0/phoenix_new-1.1.0.ez

依存関係のアップデート

mix.exsを以下のように変更する。

mix.exs
  # ...省略

  # Configuration for the OTP application.
  #
  # Type `mix help compile.app` for more information.
  def application do
    [mod: {Test, []},
     applications: [:phoenix, :phoenix_html, :cowboy, :logger, :gettext, # gettextを追加
                    :phoenix_ecto, :postgrex]]
  end

  # ...省略

  # Specifies your project dependencies.
  #
  # Type `mix help deps` for examples and options.
  defp deps do
    [{:phoenix, "~> 1.1.0"},                       # phoenixのバージョンを1.1に
     {:phoenix_ecto, "~> 2.0"},                    # phoenixのバージョンを2.0に
     {:postgrex, ">= 0.0.0"},
     {:phoenix_html, "~> 2.3"},                    # phoenixのバージョンを2.3に
     {:phoenix_live_reload, "~> 1.0", only: :dev},
     {:gettext, "~> 0.9"},                         # gettextを追加
     {:cowboy, "~> 1.0"}]
  end

  # ...省略

編集後、mix deps.update --allで依存関係を更新。

後方互換のない変更への対応

layoutなどで使っていた<%= @inner %><%= render @view_module, @view_template, assigns %>にしろ、とのことなので、まずはgrepするなりして@innnerを使っているところを洗い出す。あとは単純に置き換えればOK。

動作確認

$ mix test

テストしてmix phoenix.serverして普通にアクセスできれば問題ないかと。

12
11
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
12
11