window.User = can.Model({ findAll : 'GET <%= Rails.application.routes.url_helpers.domain_users_path('{domain_id}') %>' findOne : ('GET ' + unescape('<%= Rails.application.routes.url_helpers.domain_user_path('{domain_id}', '{id}') %>')) create : (attrs, domain_id, callback) -> url = unescape('<%= Rails.application.routes.url_helpers.domain_users_path("{domain_id}") %>').replace("{domain_id}", domain_id) return $.post(url, attrs, callback, "json") update : (attrs, url, callback) -> attrs["_method"] = "PUT" return $.ajax({ url: url type: 'POST' data: attrs dataType: 'json' success: callback }) destroy : (item, callback) -> url = unescape('<%= Rails.application.routes.url_helpers.domain_user_path('{domain_id}', '{id}') %>').replace("{domain_id}", item.virtual_domain_id).replace("{id}", item.id) return $.post(url, {"_method":"DELETE"}, callback, "json") init: () -> @validatePresenceOf ['email'] }, {}) window.User.prototype.alert = () -> alert('<%= I18n.t('alert.user') %>')