{"id":1484,"date":"2022-08-30T15:16:55","date_gmt":"2022-08-30T15:16:55","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2013\/11\/23\/rails-or-ember-object-model-breaking-browsers-pushstate-functionality-collection-of-common-programming-errors\/"},"modified":"2022-08-30T15:16:55","modified_gmt":"2022-08-30T15:16:55","slug":"rails-or-ember-object-model-breaking-browsers-pushstate-functionality-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2022\/08\/30\/rails-or-ember-object-model-breaking-browsers-pushstate-functionality-collection-of-common-programming-errors\/","title":{"rendered":"Rails or Ember object model breaking browser&#39;s pushState functionality?-Collection of common programming errors"},"content":{"rendered":"<p>** I&#8217;m using Ember.Object instead of Ember Data, to pull data from an api and I believe that might be causing the issue.**<\/p>\n<p>I have my resources nested as so:<\/p>\n<pre><code>Mdm.Router.map -&gt;\n @resource \"groups\", -&gt;\n   @resource \"group\", path: ':group_id'\n<\/code><\/pre>\n<p>&#8216;\/groups\/ loads a list of all groups on the left side of the browser. Each group is linking to its specific group_id. When clicked, the &#8216;group&#8217; template renders on the right side of the screen, showing details of one group while the list remains to the left.<\/p>\n<p>However, when you click the back button, or manually enter the group_id into the url the individual groups dont render. The url will update in the browser window, but the content wont change to match it.<\/p>\n<p>I have the singular &#8216;group&#8217; template rendering inside of the &#8216;groups&#8217; template with the {{outlet}}.<\/p>\n<p>My groups_route.js.coffee looks like this:<\/p>\n<pre><code>Mdm.GroupsRoute = Ember.Route.extend(model: -&gt;\n   Mdm.Group.all()\n)\n<\/code><\/pre>\n<p>application.hbs:<\/p>\n<pre><code>\n  \n    <img decoding=\"async\" src=\"assets\/logo_loginbox.png\" class=\"logo\" \/>\n    <\/code><\/pre>\n<ul class=\"nav-menu\">\n<li><code>GROUPS<\/code><\/li>\n<li><code>USERS<\/code><\/li>\n<\/ul>\n<pre>\n  \n  \n  {{outlet}}\n\n<\/pre>\n<p><code>groups.hbs:<\/code><\/p>\n<h1><code>Groups<\/code><\/h1>\n<pre>\n\n{{ partial groupsList }}\n\n  {{outlet}}\n\n<\/pre>\n<p><code>group.hbs:<\/code><\/p>\n<h1><code>{{name}}<\/code><\/h1>\n<pre>\n<\/pre>\n<p><code>I'm getting the following error in the console when I use the back button or try to load the page with the group_id present:<\/code><\/p>\n<pre><code><code>Uncaught TypeError: Object function () {\nif (!wasApplied) {\n  Class.proto(); \/\/ prepare prototype...\n}\no_defineProperty(this, GUID_KEY, undefinedDescriptor);\no_defineProperty(this, '_super', undefinedDescriptor);\nvar m = meta(this);\nm.proto = this;\nif (initMixins) {\n  \/\/ capture locally so we can clear the closed over variable\n  var mixins = initMixins;\n  initMixins = null;\n  this.reopen.apply(this, mixins);\n}\nif (initProperties) {\n  \/\/ capture locally so we can clear the closed over variable\n  var props = initProperties;\n  initProperties = null;\n\n  var concatenatedProperties = this.concatenatedProperties;\n\n  for (var i = 0, l = props.length; i &lt; l; i++) {\n    var properties = props[i];\n\n    Ember.assert(\"Ember.Object.create no longer supports mixing in other definitions, use createWithMixins instead.\", !(properties instanceof Ember.Mixin));\n\n    for (var keyName in properties) {\n      if (!properties.hasOwnProperty(keyName)) { continue; }\n\n      var value = properties[keyName],\n          IS_BINDING = Ember.IS_BINDING;\n\n      if (IS_BINDING.test(keyName)) {\n        var bindings = m.bindings;\n        if (!bindings) {\n          bindings = m.bindings = {};\n        } else if (!m.hasOwnProperty('bindings')) {\n          bindings = m.bindings = o_create(m.bindings);\n        }\n        bindings[keyName] = value;\n      }\n\n      var desc = m.descs[keyName];\n\n      Ember.assert(\"Ember.Object.create no longer supports defining computed properties.\", !(value instanceof Ember.ComputedProperty));\n      Ember.assert(\"Ember.Object.create no longer supports defining methods that call _super.\", !(typeof value === 'function' &amp;&amp; value.toString().indexOf('._super') !== -1));\n\n      if (concatenatedProperties &amp;&amp; indexOf(concatenatedProperties, keyName) &gt;= 0) {\n        var baseValue = this[keyName];\n\n        if (baseValue) {\n          if ('function' === typeof baseValue.concat) {\n            value = baseValue.concat(value);\n          } else {\n            value = Ember.makeArray(baseValue).concat(value);\n          }\n        } else {\n          value = Ember.makeArray(value);\n        }\n      }\n\n      if (desc) {\n        desc.set(this, keyName, value);\n      } else {\n        if (typeof this.setUnknownProperty === 'function' &amp;&amp; !(keyName in this)) {\n          this.setUnknownProperty(keyName, value);\n        } else if (MANDATORY_SETTER) {\n          Ember.defineProperty(this, keyName, null, value); \/\/ setup mandatory setter\n        } else {\n          this[keyName] = value;\n        }\n      }\n    }\n  }\n}\nfinishPartial(this, m);\ndelete m.proto;\nfinishChains(this);\nthis.init.apply(this, arguments);\n  } has no method 'find' application.js:51233\nMdm.GroupRoute.Ember.Route.extend.model application.js:51233\nsuperWrapper application.js:12849\nEmber.Route.Ember.Object.extend.deserialize application.js:36503\ncollectObjects application.js:35614\nproceed application.js:35638\n(anonymous function) application.js:1193\nfire application.js:1038\nself.fireWith application.js:1149\n(anonymous function) application.js:1200\nfire application.js:1038\nself.fireWith application.js:1149\ndone application.js:8075\nscript.onload.script.onreadystatechange\n<\/code><\/code><\/pre>\n<p id=\"rop\"><small>Originally posted 2013-11-23 09:50:15. <\/small><\/p>","protected":false},"excerpt":{"rendered":"<p>** I&#8217;m using Ember.Object instead of Ember Data, to pull data from an api and I believe that might be causing the issue.** I have my resources nested as so: Mdm.Router.map -&gt; @resource &#8220;groups&#8221;, -&gt; @resource &#8220;group&#8221;, path: &#8216;:group_id&#8217; &#8216;\/groups\/ loads a list of all groups on the left side of the browser. Each group [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1484","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/1484","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=1484"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/1484\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=1484"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=1484"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=1484"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}