初试phoenix Up And Running遇到的问题

作者 yfeiyue 所属板块 问答
刚想尝试一下phoenix,先看了一下文档学得不错。跟着文档路一下demo。果然遇到问题了。 http://www.phoenixframework.org/docs/up-and-running $ erl -v Erlang/OTP 19 [erts-8.3] [source-d5c06c6] [64-bit] [smp:4:4] [async-threads:10] [kernel-poll:false] Eshell V8.3 (abort with ^G) $ iex -v Erlang/OTP 19 [erts-8.3] [source-d5c06c6] [64-bit] [smp:4:4] [async-threads:10] [kernel-poll:false] IEx 1.4.4 运行:mix phoenix.new hello_phoenix Fetch and install dependencies? [Yn] Y * running npm install && node node_modules/brunch/bin/brunch build * * running mix deps.get We are all set! Run your Phoenix application: $ cd hello_phoenix $ mix phoenix.server You can also run your app inside IEx (Interactive Elixir) as: $ iex -S mix phoenix.server Before moving on, configure your database in config/dev.exs and run: $ mix ecto.create 运行: $ cd hello_phoenix $ mix phoenix.server 报错: warning: variable "package" does not exist and is being expanded to "package()", please use parentheses to remove the ambiguity or change the variable name /Users/yfy/work/elixir/hello_phoenix/deps/phoenix_ecto/mix.exs:14 ==> phoenix_ecto Compiling 4 files (.ex) == Compilation error on file lib/phoenix_ecto/html.ex == ** (KeyError) key :model not found in: %Phoenix.HTML.Form{data: nil, errors: {{:., [line: 12], [{:changeset, [line: 12], nil}, :errors]}, [line: 12], []}, hidden: [], id: {:name, [line: 10], nil}, impl: Phoenix.HTML.FormData.Ecto.Changeset, index: nil, name: {:name, [line: 11], nil}, options: [], params: %{}, source: {:changeset, [line: 8], nil}} (stdlib) :maps.update(:model, {:model, [line: 13], nil}, %Phoenix.HTML.Form{data: nil, errors: {{:., [line: 12], [{:changeset, [line: 12], nil}, :errors]}, [line: 12], []}, hidden: [], id: {:name, [line: 10], nil}, impl: Phoenix.HTML.FormData.Ecto.Changeset, index: nil, name: {:name, [line: 11], nil}, options: [], params: %{}, source: {:changeset, [line: 8], nil}} lib/phoenix_html/form.ex:170: anonymous fn/2 in Phoenix.HTML.Form.__struct__/1 (elixir) lib/enum.ex:1755: Enum."-reduce/3-lists^foldl/2-0-"/ expanding struct: Phoenix.HTML.Form.__struct__/1 lib/phoenix_ecto/html.ex:7: Phoenix.HTML.FormData.Ecto.Changeset.to_form/2 could not compile dependency :phoenix_ecto, "mix compile" failed. You can recompile this dependency with "mix deps.compile phoenix_ecto", update it with "mix deps.update phoenix_ecto" or clean it with "mix deps.clean phoenix_ecto" ~/work/elixir/hello_phoenix ⌚ 17:14:21 具体版本信息: $ mix deps.get connection 1.0.4 cowboy 1.1.2 cowlib 1.0.2 db_connection 1.1.2 decimal 1.3.1 ecto 1.1.1 fs 0.9.2 gettext 0.13.1 phoenix 1.1.9 phoenix_ecto 2.0.0 phoenix_html 2.9.3 phoenix_live_reload 1.0.8 plug 1.0.6 poison 1.5.2 poolboy 1.5.1 postgrex 0.13.3 ranch 1.3.2 求老司机带路。 -----------------------分隔线--------------------------- 问题已解决 参见以下链接:https://elixirforum.com/t/key-model-not-found-error-with-latest-elixir-phoenix/2449 修改mix.exs中 deps部分代码版本从 ``` defp deps do [{:phoenix, "~> 1.1.9"}, {:phoenix_ecto, "~> 2.0.0"}, {:postgrex, ">= 0.0.0"}, {:phoenix_html, "~> 2.4"}, {:phoenix_live_reload, "~> 1.0", only: :dev}, {:gettext, "~> 0.9"}, {:cowboy, "~> 1.0"}] end ``` 修改为 ``` defp deps do [{:phoenix, "~> 1.2.1"}, {:phoenix_ecto, "~> 3.0"}, {:postgrex, ">= 0.0.0"}, {:phoenix_html, "~> 2.4"}, {:phoenix_live_reload, "~> 1.0", only: :dev}, {:gettext, "~> 0.9"}, {:cowboy, "~> 1.0"}] end ``` 居然照官方文档来做还有这样的坑,确实坑。。。。。
0 回复