Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Must be attached to a session. #142

Open
dev-inigmas opened this issue Jul 16, 2014 · 3 comments
Open

Must be attached to a session. #142

dev-inigmas opened this issue Jul 16, 2014 · 3 comments

Comments

@dev-inigmas
Copy link

I just got an error that seems pretty weird to me.

Uncaught Error: Assertion Failed: Must be attached to a session. deps.js:23517
Ember.assert deps.js:23517
require.define.Ep.LazyModel.Ep.ModelPromise.extend.load deps.js:74141

Not really sure what seems to be going on. Basically, I'm trying to set an object to the primary model's "belongsTo" attribute. And then flush the session. I've done some print outs that the model I'm setting has a Session. (Should be the same session as the parent model). But I'm consistently getting this error.

Any ideas?

@dev-inigmas
Copy link
Author

Okay, so it seems like "Bindings" are interfering the session's ability to flush.

I have some business logic in some of my models. In one case, I tried making a property of a related model easier to access by creating a binding to it. For instance:

App.Foo = Ep.Model.extend
  name: Ep.attr 'string'
  bar:     Ep.belongsTo 'bar'
  bvBinding: 'bar.value'

App.Bar = Ep.Model.extend
  value: Ep.attr 'number'
  foos:   Ep.hasMany 'foo', inverse: 'bar'

Replacing with binding with a computed property seems to be a good workaround for now.

@ghempton
Copy link
Contributor

Ah I could see this happening in some binding cases. I am working on a
refactor that could fix some of these issues.

On Wed, Jul 16, 2014 at 1:02 AM, David Patrick [email protected]
wrote:

Okay, so it seems like "Bindings" are interfering the session's ability to
flush.

I have some business logic in some of my models. In one case, I tried
making a property of a related model easier to access by creating a binding
to it. For instance:

App.Foo = Ep.Model.extend
name: Ep.attr 'string'
bar: Ep.belongsTo 'bar'
bvBinding: 'bar.value'

App.Bar = Ep.Model.extend
value: Ep.attr 'number'
foos: Ep.hasMany 'foo', inverse: 'bar'

Replacing with binding with a computed property seems to be a good
workaround for now.


Reply to this email directly or view it on GitHub
#142 (comment).

Gordon L. Hempton
http://codebrief.com
360.460.8098

@ghempton
Copy link
Contributor

Also, fwiw, I would recommend using computed property aliases rather than bindings (which are eagerly evaluated). In your case it would be bv: Ember.computed.alias('bar.value')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants