How do i check if a variable exist, in eex?

前端 未结 2 1136
抹茶落季
抹茶落季 2021-02-06 23:51

I\'m working on the crud part of a model, to which i\'ve added image support to. Ideally i would like to show the image if you are editing a model, which i would do like this.

2条回答
  •  灰色年华
    2021-02-07 00:37

    The selected answer doesn't work.

    Try with this :

    <%= if Map.has_key?(assigns, :company) do %>
      <%= Logo.url({@company.logo, @company}, :thumb) %>
    <% end %>
    

提交回复
热议问题