Phoenix安装失败:编译错误,(KeyError)键:找不到模型 [英] Phoenix setup failing: Compilation error, (KeyError) key :model not found

查看:112
本文介绍了Phoenix安装失败:编译错误,(KeyError)键:找不到模型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在运行postgres,并且可以连接到它,但是可以通过mix phoenix.new reporting使用全新的phoenix应用程序.我无法完成设置,不能执行ecto.create,我能告诉的最好的是它没有连接到数据库...或者可能是其他一些错误...基本上,我不知道该去哪里从这里.

I have postgres running and can connect to it, but a brand new phoenix app via mix phoenix.new reporting. I can not complete setup, can not do ecto.create and the best I can tell is that it didn't connect to the database... or maybe it's some other bug... bascially, I don't know where to go from here.

$ psql -p 5432 -h localhost reporting_dev postgres
Password for user postgres:
psql (9.6.1, server 9.6.2)
Type "help" for help.

reporting_dev=#

这是我的config/dev.exs

$ grep Reporting.Repo -A 6 config/dev.exs
config :reporting, Reporting.Repo,
  adapter: Ecto.Adapters.Postgres,
  username: "postgres",
  password: "postgres",
  database: "reporting_dev",
  hostname: "localhost",
  pool_size: 10

但我无法完成ecto.create

$ mix ecto.create
warning: variable "aliases" does not exist and is being expanded to "aliases()", please use parentheses to remove the ambiguity or change the variable name
  mix.exs:12

warning: variable "deps" does not exist and is being expanded to "deps()", please use parentheses to remove the ambiguity or change the variable name
  mix.exs:13

warning: variable "deps" does not exist and is being expanded to "deps()", please use parentheses to remove the ambiguity or change the variable name
  /Users/alan/Code/eltoro/reporting/deps/phoenix_ecto/mix.exs:10

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/alan/Code/eltoro/reporting/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-"/3
    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"

这是我的基本版本

$ elixir -v
Erlang/OTP 19 [erts-8.2] [source] [64-bit] [smp:8:8] [async-threads:10] [hipe] [kernel-poll:false] [dtrace]

Elixir 1.4.1

$ uname -a
Darwin alan-MBP.local 15.6.0 Darwin Kernel Version 15.6.0: Mon Jan  9 23:07:29 PST 2017; root:xnu-3248.60.11.2.1~1/RELEASE_X86_64 x86_64 i386 MacBookPro11,5 Darwin

$ node --version
v6.7.0

推荐答案

是否是您使用的是Phoenix.HTML的1.x版本,而您应该使用2.x.

Could it be that you are using a 1.x version of Phoenix.HTML, where as you should use 2.x.

在1.x版中,使用了模型一词,而不是在2.x版和最新的Phoenix版本中使用的模式.

In version 1.x, the term model was used, over schema, which is used in 2.x and in the latest Phoenix version.

https://github.com /phoenixframework/phoenix_html/blob/v1.4.0/lib/phoenix_html/form.ex#L166

vs

https://github.com /phoenixframework/phoenix_html/blob/v2.9.3/lib/phoenix_html/form.ex#L170

这篇关于Phoenix安装失败:编译错误,(KeyError)键:找不到模型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆