gpt4 book ai didi

phoenix-framework - 编译错误: module Ecto.模型未加载且无法找到

转载 作者:行者123 更新时间:2023-12-02 03:14:06 26 4
gpt4 key购买 nike

得到编译问题,请看一下,可能大家都熟悉这个错误

== 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)

Controller

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// Controller 部分

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

结束

最佳答案

删除了 Ecto.Model 中的“模型”,因为使用 Ecto.Model 已被弃用并删除

谢谢@Dogbert 的帮助。

关于phoenix-framework - 编译错误: module Ecto.模型未加载且无法找到,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41682131/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com