I am having errors with using my old views/layouts moved into a new Phoenix 1.7 application. Even though I have phoenix_view installed, it still trhows errors about templates not available. I desperately need help on how to handle this.
This is my router_web.ex include view and view_helpers
defmodule RationWeb do
@moduledoc """
The entrypoint for defining your web interface, such
as controllers, components, channels, and so on.
This can be used in your application as:
use RationWeb, :controller
use RationWeb, :html
The definitions below will be executed for every controller,
component, etc, so keep them short and clean, focused
on imports, uses and aliases.
Do NOT define functions inside the quoted expressions
below. Instead, define additional modules and import
those modules here.
"""
def static_paths, do: ~w(assets fonts images favicon.ico robots.txt)
def router do
quote do
use Phoenix.Router, helpers: true
# Import common connection and controller functions to use in pipelines
import Plug.Conn
import Phoenix.Controller
import Phoenix.LiveView.Router
end
end
def channel do
quote do
use Phoenix.Channel
end
end
def controller do
quote do
use Phoenix.Controller,
formats: [:html, :json],
layouts: [html: RationWeb.Layouts]
import Plug.Conn
import RationWeb.Gettext
unquote(verified_routes())
end
end
def view do
quote do
use Phoenix.View,
root: "lib/ration_web/templates",
namespace: RationWeb,
pattern: "**/*"
# Import convenience functions from controllers
import Phoenix.Controller,
only: [get_flash: 1, get_flash: 2, view_module: 1, view_template: 1]
# Include shared imports and aliases for views
unquote(view_helpers())
end
end
defp view_helpers do
quote do
# Use all HTML functionality (forms, tags, etc)
use Phoenix.HTML
# Import basic rendering functionality (render, render_layout, etc)
import Phoenix.View
import RationWeb.ErrorHelpers
import RationWeb.Gettext
alias RationWeb.Router.Helpers, as: Routes
end
end
def live_view do
quote do
use Phoenix.LiveView,
layout: {RationWeb.Layouts, :app}
unquote(html_helpers())
end
end
def live_component do
quote do
use Phoenix.LiveComponent
unquote(html_helpers())
end
end
def html do
quote do
use Phoenix.Component
# Import convenience functions from controllers
import Phoenix.Controller,
only: [get_csrf_token: 0, view_module: 1, view_template: 1]
# Include general helpers for rendering HTML
unquote(html_helpers())
end
end
defp html_helpers do
quote do
# HTML escaping functionality
import Phoenix.HTML
# Core UI components and translation
import RationWeb.CoreComponents
import RationWeb.Gettext
# Shortcut for generating JS commands
alias Phoenix.LiveView.JS
# Routes generation with the ~p sigil
unquote(verified_routes())
end
end
def verified_routes do
quote do
use Phoenix.VerifiedRoutes,
endpoint: RationWeb.Endpoint,
router: RationWeb.Router,
statics: RationWeb.static_paths()
end
end
@doc """
When used, dispatch to the appropriate controller/view/etc.
"""
defmacro __using__(which) when is_atom(which) do
apply(__MODULE__, which, [])
end
end
And a snippet of the controller with action throwing error
defmodule RationWeb.UserSessionController do
use RationWeb, :controller
alias RationWeb.UserAuth
alias RationWeb.WdApi
alias Ration.Utilities
alias Ration.Database
# alias Ration.Tenants
# # plug :put_layout, "landing.html"
# plug :put_layout, html: {RationWeb.Layouts, :root}
plug :put_layout, html: {RationWeb.UserSessionView, :landing}
def new(conn, params) do
host = conn.host
subdomain = get_subdomain(host)
license = Ration.Establishments.get_main_license()
titles = case license.edition do
"dc-on-premise" ->
Ration.Tenants.fetch_titles("")
_ ->
Ration.Tenants.fetch_titles(subdomain)
end
uidet = case license.edition do
"dc-on-premise" ->
Ration.Tenants.fetch_default_bg_image()
_ ->
Ration.Tenants.fetch_bg_image(subdomain)
end
logoimg = case license.edition do
"dc-on-premise" ->
Ration.Tenants.fetch_default_logo_image()
_ ->
Ration.Tenants.fetch_logo(subdomain)
end
layoutPage = case license.edition do
"dc-on-premise" ->
Ration.Tenants.fetch_default_layout()
_ ->
Ration.Tenants.fetch_layout(subdomain)
end
if layoutPage["layout"] == "juxtaposing" do
case Database.check_db(subdomain) do
{:ok, _db_name} ->
conn
|> assign(:tenant, subdomain)
|> render("new.html", error_message: params["error_message"], titles: titles, uidet_bgimg: uidet["img"], logo_img: logoimg["img"], layout: {RationWeb.LayoutView, "landing_two.html"}, content: layoutPage["content"])
_ ->
conn
|> assign(:tenant, subdomain)
|> render("new.html", error_message: params["error_message"], titles: titles, uidet_bgimg: uidet["img"], logo_img: logoimg["img"], layout: {RationWeb.LayoutView, "landing_two.html"}, content: layoutPage["content"])
end
else
case Database.check_db(subdomain) do
{:ok, _db_name} ->
conn
|> assign(:tenant, subdomain)
|> render("new.html", error_message: params["error_message"], titles: titles, uidet_bgimg: uidet["img"], logo_img: logoimg["img"], layout: {RationWeb.LayoutView, "landing.html"}, content: layoutPage["content"])
_ ->
conn
|> assign(:tenant, subdomain)
|> render("new.html", error_message: params["error_message"], titles: titles, uidet_bgimg: uidet["img"], logo_img: logoimg["img"], layout: {RationWeb.LayoutView, "landing.html"})
end
end
end
And the error
[debug] Processing with RationWeb.UserSessionController.new/2
Parameters: %{}
Pipelines: [:browser, :user, :redirect_if_user_is_authenticated]
[debug] Plug.Session could not verify incoming session cookie. This may happen when the session settings change or a stale cookie is sent.
[info] Sent 500 in 88ms
[error] #PID<0.650.0> running Phoenix.Endpoint.SyncCodeReloadPlug (connection #PID<0.647.0>, stream id 1) terminated
Server: localhost:4000 (http)
Request: GET /users/log_in
** (exit) an exception was raised:
** (ArgumentError) no "new" html template defined for RationWeb.UserSessionHTML (the module does not exist)
(phoenix_template 1.0.3) lib/phoenix/template.ex:248: Phoenix.Template.render_with_fallback/4
(phoenix_template 1.0.3) lib/phoenix/template.ex:197: Phoenix.Template.render_within_layout/4
(phoenix 1.7.10) lib/phoenix/controller.ex:1000: anonymous fn/5 in Phoenix.Controller.template_render/4
(telemetry 1.2.1) /Users/osindero/dev/active/ration/deps/telemetry/src/telemetry.erl:321: :telemetry.span/3
(phoenix 1.7.10) lib/phoenix/controller.ex:987: Phoenix.Controller.render_with_layouts/4
(phoenix 1.7.10) lib/phoenix/controller.ex:974: Phoenix.Controller.render_and_send/4
(ration 0.1.0) lib/ration_web/controllers/user_session_controller.ex:1: RationWeb.UserSessionController.action/2
(ration 0.1.0) lib/ration_web/controllers/user_session_controller.ex:1: RationWeb.UserSessionController.phoenix_controller_pipeline/2
(phoenix 1.7.10) lib/phoenix/router.ex:432: Phoenix.Router.__call__/5
(ration 0.1.0) lib/ration_web/endpoint.ex:1: RationWeb.Endpoint.plug_builder_call/2
(ration 0.1.0) deps/plug/lib/plug/debugger.ex:136: RationWeb.Endpoint."call (overridable 3)"/2
(ration 0.1.0) lib/ration_web/endpoint.ex:1: RationWeb.Endpoint.call/2
(phoenix 1.7.10) lib/phoenix/endpoint/sync_code_reload_plug.ex:22: Phoenix.Endpoint.SyncCodeReloadPlug.do_call/4
(plug_cowboy 2.6.1) lib/plug/cowboy/handler.ex:11: Plug.Cowboy.Handler.init/2
(cowboy 2.10.0) /Users/osindero/dev/active/ration/deps/cowboy/src/cowboy_handler.erl:37: :cowboy_handler.execute/2
(cowboy 2.10.0) /Users/osindero/dev/active/ration/deps/cowboy/src/cowboy_stream_h.erl:306: :cowboy_stream_h.execute/3
(cowboy 2.10.0) /Users/osindero/dev/active/ration/deps/cowboy/src/cowboy_stream_h.erl:295: :cowboy_stream_h.request_process/3
(stdlib 3.17.2.1) proc_lib.erl:226: :proc_lib.init_p_do_apply/3
And this is the error I am