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:
the owner.id
a is string and current_user.id
is a number
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 a parse
method to your model to fix it for you:
parse: function(response) {
if(response.id)
response.id = +response.id // or parseInt(response.id, 10) if you prefer
return response;
}