grych / drab

Remote controlled frontend framework for Phoenix.

Home Page:https://tg.pl/drab

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Phoenix.Template.UndefinedError when using drab in nerves

chrta opened this issue · comments

When i extend the hello_phoenix example from nerves with the instructions from the drab README, it works fine locally. But when i build the nerves firmware according to https://github.com/chrta/nerves_examples/blob/phoenix_with_drab/hello_phoenix/README.md for the raspberry pi 1 (MIX_TARGET=rpi) i get the error at the bottom.

Source code:
https://github.com/chrta/nerves_examples/tree/phoenix_with_drab/hello_phoenix

00:08:12.084 [info]  GET /
        
00:08:12.086 [debug] Processing with UiWeb.PageController.index/2
  Parameters: %{}
  Pipelines: [:browser]
        
00:08:12.088 [info]  Sent 500 in 3ms
        
00:08:12.129 [error] #PID<0.659.0> running UiWeb.Endpoint (cowboy_protocol) terminated
Server: 192.168.180.45:80 (http)
Request: GET /
** (exit) an exception was raised:
    ** (Phoenix.Template.UndefinedError) Could not render "index.html" for UiWeb.PageView, please define a matching clause for render/2 or define a template at "lib/ui_web/templates/page". No templates were compiled for this module.
Assigns:

%{conn: %Plug.Conn{adapter: {Plug.Adapters.Cowboy.Conn, :...}, assigns: %{layout: {UiWeb.LayoutView, "app.html"}, welcome_text: "Welcome to Phoenix!"}, before_send: [#Function<0.116269836/1 in Plug.CSRFProtection.call/2>, #Function<4.121726256/1 in Phoenix.Controller.fetch_flash/2>, #Function<0.58261320/1 in Plug.Session.before_send/2>, #Function<1.25166163/1 in Plug.Logger.call/2>], body_params: %{}, cookies: %{}, halted: false, host: "192.168.180.45", method: "GET", owner: #PID<0.659.0>, params: %{}, path_info: [], path_params: %{}, peer: {{192, 168, 178, 25}, 55246}, port: 80, private: %{UiWeb.Router => {[], %{}}, :phoenix_action => :index, :phoenix_controller => UiWeb.PageController, :phoenix_endpoint => UiWeb.Endpoint, :phoenix_flash => %{}, :phoenix_format => "html", :phoenix_layout => {UiWeb.LayoutView, :app}, :phoenix_pipelines => [:browser], :phoenix_router => UiWeb.Router, :phoenix_template => "index.html", :phoenix_view => UiWeb.PageView, :plug_session => %{}, :plug_session_fetch => :done}, query_params: %{}, query_string: "", remote_ip: {192, 168, 178, 25}, req_cookies: %{}, req_headers: [{"host", "192.168.180.45"}, {"connection", "keep-alive"}, {"cache-control", "max-age=0"}, {"upgrade-insecure-requests", "1"}, {"user-agent", "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.81 Safari/537.36"}, {"accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8"}, {"accept-encoding", "gzip, deflate"}, {"accept-language", "de-DE,de;q=0.9,en-US;q=0.8,en;q=0.7"}], request_path: "/", resp_body: nil, resp_cookies: %{}, resp_headers: [{"cache-control", "max-age=0, private, must-revalidate"}, {"x-frame-options", "SAMEORIGIN"}, {"x-xss-protection", "1; mode=block"}, {"x-content-type-options", "nosniff"}, {"x-download-options", "noopen"}, {"x-permitted-cross-domain-policies", "none"}], scheme: :http, script_name: [], secret_key_base: "HEY05EB1dFVSu6KykKHuS4rQPQzSHv4F7mGVB/gnDLrIu75wE/ytBXy2TaL3A6RA", state: :unset, status: nil}, template_not_found: UiWeb.PageView, view_module: UiWeb.PageView, view_template: "index.html", welcome_text: "Welcome to Phoenix!"}

Assigned keys: [:conn, :template_not_found, :view_module, :view_template, :welcome_text]

        (phoenix) lib/phoenix/template.ex:364: Phoenix.Template.raise_template_not_found/3
        (ui) lib/ui_web/templates/layout/app.html.eex:29: UiWeb.LayoutView."app.html"/1
        (phoenix) lib/phoenix/view.ex:332: Phoenix.View.render_to_iodata/3
        (phoenix) lib/phoenix/controller.ex:740: Phoenix.Controller.do_render/4
        (ui) lib/ui_web/controllers/page_controller.ex:1: UiWeb.PageController.action/2
        (ui) lib/ui_web/controllers/page_controller.ex:1: UiWeb.PageController.phoenix_controller_pipeline/2
        (ui) lib/ui_web/endpoint.ex:1: UiWeb.Endpoint.instrument/4
        (phoenix) lib/phoenix/router.ex:278: Phoenix.Router.__call__/1
iex(5)> 

This was my fault (i think, i am not very familiar with elixir, nerves and phoenix):
The drabs template configuration must be placed in the mix config for the nerves fimware. Then it works fine!
Thank you for your support.

Cool, good to know!