编译错误:模块Ecto.Model未加载且无法找到

时间:2017-01-16 17:45:21

标签: elixir phoenix-framework ecto elixir-framework

获取编译问题,请看一下,可能是任何人都熟悉错误

== Compilation error on file web/controllers/order_controller.ex ==
** (CompileError) web/controllers/order_controller.ex:2: module Ecto.Model is     not loaded and could not be found
expanding macro: PhoenixCart.Web.__using__/1
web/controllers/order_controller.ex:2: PhoenixCart.OrderController (module)
(elixir) expanding macro: Kernel.use/2
web/controllers/order_controller.ex:2: PhoenixCart.OrderController (module)

控制器

defmodule PhoenixCart.OrderController do
  use PhoenixCart.Web, :controller

  alias PhoenixCart.Order

   plug :scrub_params, "order" when action in [:create, :update]

  def index(conn, _params) do
    orders = Repo.all(Order)
    render(conn, "index.html", orders: orders)
  end
  ##<more code>
end

web.exs //控制器部分

def controller do
    quote do
      use Phoenix.Controller

  # Alias the data repository and import query/model functions
  alias PhoenixCart.Repo

  import Ecto.Model
  import Ecto.Query, only: [from: 2]

  # Import URL helpers from the router
  import PhoenixCart.Router.Helpers
end

1 个答案:

答案 0 :(得分:3)

删除了Ecto.Model中的'Model',因为已弃用并删除了使用Ecto.Model

感谢@Dogbert,寻求帮助。