0
votes

I am following an intro tutorial from trek.github.com, and I ran into the error in the title when running it. Paste is available, error occurred on line 119. In the meanwhile, I'd like to use this thread for a few EmberJS newbie questions:

  1. What is the difference between an Ember.ObjectController and Ember.Object?
  2. On line 70, there is an occurrence of .fmt(this.get('login')) after an URL. What does this do?
  3. I noticed that Ember can process variable URL names, using the '/:VAR' notation. Just wondering, if multiple variable URL names occur, how does EmberJS manage them if there are duplications? Is it a good practice to use variable URL names?
  4. The example came with serialize and deserialized function (from line 107) to grab login names. But I don't see them called anywhere.

Thanks for your patience, Angela

1

1 Answers

0
votes

I'm afraid that you're using an old version of Ember here, Angela. You're using pre 2, whereas the latest version is pre 4. I recommend you use pre 4 because a lot has changed. For example, looking at your line #119, I can tell you straight away that there's no connectOutlets method any more in pre 4.

With all that said, I think your problem is, from a cursory glance, that you're attempting to call loadMoreDetails on the content of the controller, rather than the controller itself. Try: router.get('oneContributorController').loadMoreDetails();

Furthermore, there is no access to the router any more in pre 4. I think it's crucial you update.

Questions

  1. Ember.Object represents a single object, whereas Ember.ObjectController is more about a collection for storing many Ember.Objects. You should be using either Ember.ArrayController (an array of similar objects), Ember.ObjectController (a container for many different related objects) or Ember.Controller (generic usage) depending on your use case.

  2. What is your background? Ruby or PHP? Either way, the fmt method is like PHP's sprintf and Rails' % operator ("Tasks: %d" % @tasksCount). The %@ is to specify where the value of get('login); will appear in the string.

  3. Ember doesn't specify the name of the variables in the URL itself. Not by default, any way. It's your router (you're using router v1, whereas it's router v2 in pre 4) that tells Ember which part of the URL maps to which property. With this there are no duplicates, because each variable has its own unique space in the URL.

  4. Those are from the old Ember that you're using. In the new version they are more intuitive. To tell a controller which model(s) it should represent, you have a model method in the router that returns the correct model. In the version you're using, they tell Ember how to create the object from the URL parameters (deserialize - why do you have deserialized?), and vice-versa, to get the property for the URL from the object you passed in (serialize).

P.S: I think you'll find my post from yesterday quite an informative read.