It's Eco, the problem is it should add button just for some models(backbone) in partial, but the statment if not worked.The variables are accessible, but the owner.id a is string and current_user.id is a number.
<% if @owner?.id is current_user.id: %>
<div class="info-add">
<button class="button secondary tiny radius">
<i class="fi-plus"></i>
Add
</button>
</div>
<% end %>
Eco uses CoffeeScript as the template language and in CoffeeScript,
is
and==
become===
in the JavaScript version. JavaScript's strict equality operator (===
) doesn't do the type conversions that==
will do so'6' === 6
is false even though'6' == 6
is true.You say that:
so
@owner.id is current_user.id
will always be false.If your client code is generating the
id
as a string then it is broken and you should fix it. If your server is sending@owner.id
as a string then your server is broken and you should fix your server to send out the correct JSON; if you can't fix the server code then you could add aparse
method to your model to fix it for you: