title: phoenix pass variable to view
body: <p>i have a query result that will be used in view, but when i call the variable in view, i got <code>undefined function data/0</code> (because data is not function)</p>
  
  <p>i already pass data with different way, map, etc</p>
  
  <p>controller.ex :</p>
  
  <pre><code>def new(conn, _params) do
      data =
          Enum.map(
            from(AccountTypeSchema)
            |&gt; Repo.all(),
            fn elem -&gt;
              elem |&gt; Map.from_struct() |&gt; Map.delete(:__meta__)
            end
          )
      render(conn, "new.html", data: data)
  end
  </code></pre>
  
  <p>view.html.eex :</p>
  
  <pre><code>&lt;% Enum.each data, fn(item) -&gt; %&gt;
      &lt;option value="us"&gt;Facebook&lt;/option&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p>call <code>data</code> variable from view</p>