页面在localhost上完全加载,但在尝试实时访问时,我收到内部服务器500错误。 Heroku日志输出:
(Phoenix.Template.UndefinedError) Could not render "index.html" for Driverless.Web.MainplayersView, please define a matching clause for render/2 or define a template at "lib/driverless/web/templates/mainplayers". No templates were compiled for this module.
导致这种情况的原因。我99%确定我拥有所有正确的文件。
控制器
defmodule Driverless.Web.MainplayersController do
use Driverless.Web, :controller
def index(conn, _params) do
render conn, "index.html"
end
end
查看
defmodule Driverless.Web.MainplayersView do
use Driverless.Web, :view
end
模板/ mainplayers / index.html.eex
//Just a load of html.
路由器
defmodule Driverless.Web.Router do
use Driverless.Web, :router
pipeline :browser do
plug :accepts, ["html"]
plug :fetch_session
plug :fetch_flash
plug :protect_from_forgery
plug :put_secure_browser_headers
end
pipeline :api do
plug :accepts, ["json"]
end
scope "/", Driverless.Web do
pipe_through :browser # Use the default browser stack
get "/", PostController, :index
resources "/posts", PostController
get "/about", AboutController, :index
get "/mainplayers", MainplayersController, :index
end
# Other scopes may use custom stacks.
# scope "/api", Driverless.Web do
# pipe_through :api
# end
end
这可能是文件名中的拼写错误吗?不知道为什么它在本地机器上工作正常,但在Heroku上没有。其他静态页面加载正常。