window.Domain = can.Model({ findAll : 'GET <%= Rails.application.routes.url_helpers.domains_path %>' findOne : ('GET ' + unescape('<%= Rails.application.routes.url_helpers.domain_path('{id}') %>')) create : (attrs, callback) -> url = '<%= Rails.application.routes.url_helpers.domains_path %>' return $.post(url, attrs, callback, "json") update : (attrs, domain ) -> url = unescape('<%= Rails.application.routes.url_helpers.domain_path('{id}') %>').replace('{id}', domain.id) return $.post(url, attrs, null, "json") destroy : (item, callback) -> url = unescape('<%= Rails.application.routes.url_helpers.domain_path('{id}') %>').replace("{id}", item.id) return $.post(url, {"_method":"DELETE"}, callback, "json") attributes: { virtual_users: 'Models.User.models', virtual_aliases: 'Models.Alias.models' }, init: () -> @validateFormatOf ['name'], /^(?:[-a-z0-9]+\.)+[a-z]{2,}$/i }, {}) window.Domain.List = can.Model.List({ with_id: (id) -> the_one = null @each (domain) -> if (domain.id == id) the_one = domain return domain return the_one }) window.Domain.prototype.alert = () -> alert('<%= I18n.t('alert.domain') %>')