function Phoenix.HTML.Engine.fetch_assign/2 is undefined or private
DennisKh opened this issue · comments
When I use the file name without .drab I have this error:
[error] Drab Handler failed with the following exception: ** (ArgumentError) template
index.html` not found.
Please make sure this partial exists and has been compiled
by Drab (has *.drab extension).
If you want to poke assign to the partial which belong to
the other view, you need to specify the view name in poke/4
.
(drab) lib/drab/live.ex:1019: Drab.Live.raise_partial_not_found/1
(drab) lib/drab/live.ex:895: Drab.Live.assigns_for_partial/5
(drab) lib/drab/live.ex:605: Drab.Live.do_poke/5
(drab) lib/drab.ex:360: anonymous fn/7 in Drab.handle_event/6`
When i add .drab, got this:
function Phoenix.HTML.Engine.fetch_assign/2 is undefined or private
Here mix.exe
[ {:phoenix, "~> 1.3.4"}, {:phoenix_pubsub, "~> 1.0"}, {:phoenix_ecto, "~> 3.4"}, {:mariaex, "~> 0.8.4"}, {:phoenix_html, "~> 2.10"}, {:phoenix_live_reload, "~> 1.0", only: :dev}, {:gettext, "~> 0.11"}, {:cowboy, "~> 1.0"}, {:plug_cowboy, "~> 1.0"}, {:drab, "~> 0.10.0"}, {:ecto, "~> 2.2.1"}, {:tzdata, "0.5.19"}, {:timex, "3.4.2"}, {:distillery, "~> 2.0", runtime: false} ]
Can you check what version of phoenix_html
you have?
mix deps | grep phoenix_html
Also, could you please check if you have Phoenix.HTML.Engine.fetch_assign!/2
(with bang) function available in your environment?
Also, could you please check if you have
Phoenix.HTML.Engine.fetch_assign!/2
(with bang) function available in your environment?
I thought the same way. I just changed the version of phoenix_httm to 2.12.0. it's works for me.
Thank you for having responded!
Can someone explain why this error occurred?
OK, so the case is solved.
Jose have changed this function name (here) in this commit.
Unfortunately, Drab is a bit of hack over the Phoenix, so we need to use undocumented functions. I am going to bump up the version of phoenix_html in the next Drab release.
I am reopening as it needs to be fixed.
I am reopening as it needs to be fixed.
Ok
I have the same issue. My environment is as follows:
Drab 0.9.3
Phoenix 1.3.4
Phoenix_html 2.13.0
Thanks for the help
Please lock the phoenix_html to 2.12, I will release a fix shortly
done.... everything compiles ok.... thanks... but. Can this error be related?
I am getting a alter in the browser: "An error occured. Please contact the System Administrator"
20:12:06.347 [error] Drab Handler failed with the following exception:
** (ArgumentError) assign @changeset not available in eex template.
Please make sure all proper assigns have been set. If this
is a child template, ensure assigns are given explicitly by
the parent template as they are not automatically forwarded.
Available assigns: [:action, :conn, :parent, :po_grantotal, :type, :view_module, :view_template]
(phoenix_html) lib/phoenix_html/engine.ex:116: Phoenix.HTML.Engine.fetch_assign/2
(epr) lib/epr_web/templates/payment_order/form.html.drab:1: EprWeb.PaymentOrderView."form.html"/1
(epr) lib/epr_web/templates/payment_order/new.html.drab:6: EprWeb.PaymentOrderView."new.html"/1
(phoenix) lib/phoenix/view.ex:332: Phoenix.View.render_to_iodata/3
(phoenix) lib/phoenix/view.ex:339: Phoenix.View.render_to_string/3
(drab) lib/drab/live.ex:674: Drab.Live.rerender_template/4
(drab) lib/drab/live.ex:629: Drab.Live.process_poke/9
(drab) lib/drab.ex:360: anonymous fn/7 in Drab.handle_event/6
Hi @joaquinalcerro,
it looks like you are trying to poke
the assign @changeset
which is not defined in the template.
I am not trying to poke the changeset.
This is my actual code:
Commander:
defmodule EprWeb.PaymentOrderCommander do
use Drab.Commander
defhandler invoice_selected(socket, _sender) do
poke socket, po_grantotal: 1000 * 1
end
end
_invoices.html.drab Template:
<%= form_for @changeset, @action, fn f -> %>
<div class="row">
<div class="col-md-12">
<%= render "_invoices.html", conn: @conn, invoices: @invoices, parent: @parent %>
</div>
.......
_invoice_details.html.drab Template:
<tr name="invoice">
<td>
<span class="text-right">
<input type="hidden" name="invoices[<%= @invoice.id %>][paid]" value="false">
<input type="checkbox" id="<%= @invoice.id %>" name="invoices[<%= @invoice.id %>][paid]" value="true" drab-change="invoice_selected" checked>
</span>
</td>
<td><%= @invoice.proforma_invoice_number %></td>
<td><%= @invoice.exempt_order_number %></td>
<td><%= @invoice.invoice_number %></td>
<td><%= @invoice.date %></td>
<td class="<%= active_icon(@invoice.exempt) %>"></td>
........
Is the @changeset
assign used it them main template (the one which is not a partial)?
Also, could you pls upgrade Drab to 0.10?
Thanks, I will do the update.
This is the main template:
new.html.drab
<p class="title1">Nueva orden de pago</p>
render "form.html", Map.put(assigns, :action, contract_payment_order_path(@conn, :create, @parent))
This is the controller:
def new(conn, _params, %Epr.Debts.Contract{} = document) do
invoices = Epr.Debts.list_unpaid_invoices(document)
changeset =
%PaymentOrder{}
|> Payments.new_payment_order()
render(
conn,
"new.html",
changeset: changeset,
parent: document,
invoices: invoices,
bank_accounts: Epr.Payments.list_all_bank_accounts(),
currency_us: document.currency_us,
po_grantotal: 0,
type: "contract"
)
end
_invoices.html.drab template:
...........
<tbody>
<%=
case @parent do
%Epr.Partners.Provider{} ->
for i <- @invoices do
render "_invoice_details.html", invoice: i, currency: i.currency_us
end
_ ->
for i <- @invoices do
render "_invoice_details.html", invoice: i, currency: @parent.currency_us
end
end
%>
</tbody>
</table>
.........
Please note my mistake with the previous post. The main form is:
form.html.drab
<%= form_for @changeset, @action, fn f -> %>
<div class="row">
<div class="col-md-12">
<%= render "_invoices.html", conn: @conn, invoices: @invoices, parent: @parent %>
</div>
.......
Is the assign @changeset
used anywhere in new.html
? (BTW by main template I mean new.html, as it is rendered from the controller.
Can you create a new issue for that? We are very offtopic for this specific issue :)
I got this error, too.
The reason is quite simple.
phoenix_html
has changed the function name from Phoenix.HTML.Engine.fetch_assign/2
to Phoenix.HTML.Engine.fetch_assign!/2
last November. Here is the commit v2.13.1
I think just replacing the function name would solve this error, but there may be other problems since some functions are changed as well. (ex. handle_expr
changed arguments.)
This was not a good versioning..
I followed Grych recomendation:
In my case, I had no problems with this lock but waiting for his fix to update all.