小编pio*_*rze的帖子

如何调试eex模板和@变量?

我有这个模板

  <%= form_for @changeset, bid_path(@conn, :update, 1), [method: :put], fn f -> %>
    <% 
      require IEx
      IEx.pry
    %>
<%= if @changeset.action do %>
  <div class="alert alert-danger">
    <p>Oops, something went wrong! Please check the errors below.</p>
  </div>
<% end %>
Run Code Online (Sandbox Code Playgroud)

如何在IEx控制台中显示@changeset?当我试图这样做时,会出现错误:

pry(5)> @changeset
** (ArgumentError) cannot invoke @/1 outside module
    (elixir) lib/kernel.ex:3960: Kernel.assert_module_scope/3
    (elixir) expanding macro: Kernel.@/1
             web/templates/bid/edit.html.eex:5: (file)
Run Code Online (Sandbox Code Playgroud)

elixir phoenix-framework

5
推荐指数
1
解决办法
691
查看次数

标签 统计

elixir ×1

phoenix-framework ×1