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

session is not defined #29

Closed
hashg opened this issue Jul 23, 2013 · 2 comments
Closed

session is not defined #29

hashg opened this issue Jul 23, 2013 · 2 comments
Labels

Comments

@hashg
Copy link

hashg commented Jul 23, 2013

<!DOCTYPE html>
<html>
<head>
 <title>EmberJS epf</title>
 <meta charset="utf-8"/>
</head>
<body>  
  <script src="js/libs/jquery-1.9.1.js"></script>
  <script src="js/libs/handlebars-1.0.0-rc.4.js"></script>
  <script src="js/libs/ember-1.0.0-rc.6.js"></script>
  <script src="js/libs/epf.js"></script>
  <script type="text/javascript">
  (function(){
   //epf version 0.1.1
    var attr = Ep.attr, hasMany = Ep.hasMany, belongsTo = Ep.belongsTo;
    var App = window.App = Ember.Application.create();
    App.Project = Ep.Model.extend({
      name: attr('string'),
      updated: attr('string'),
      created: attr('string'),
      sprints: hasMany('App.Sprint')
    });

    App.Sprint = Ep.Model.extend({
      name: attr('string'),
      updated: attr('string'),
      created: attr('string'),
      project: belongsTo('App.Project')
    });
  })();
  </script>
</body>
</html>

In chrome browser console, when I type session. I get this error:

ReferenceError: session is not defined
get stack: function () { [native code] }
message: "session is not defined"
set stack: function () { [native code] }
__proto__: Error

this.session output is undefined

What might be wrong here?

@ghempton
Copy link
Contributor

The session is injected into controllers and routes. For instance, if you were inside your route's model method, you could access the session with this.session.

To access the session from the chrome console, you must manually look it up on the container: App.__container__.lookup('session:main').

Also, see #4 about defining relationships with strings (as I see your code is doing that).

@ghempton
Copy link
Contributor

I'm going to close this issue, feel free to keep questions coming.

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

No branches or pull requests

2 participants