How do I upgrade revision in emberjs DS.Store - ember.js

I am new to emberJS and I was wondering one thing about the DS.Store revision value.
From the documentation and Katz's peepcode video (which I highly recommend), you get a nice little error message in the console when the revision is too high, for instance:
App.store = DS.Store.create({
revision: 11,
adapter: DS.RESTAdapter.create({
namespace: 'api'
})
});
Could return:
Uncaught Error: Error: The Ember Data library has had breaking API changes since the last time you updated the library. Please review the list of breaking changes at https://github.com/emberjs/data/blob/master/BREAKING_CHANGES.md, then update your store's `revision` property to 4
I understand that, when this message is displayed, you have got to refer back to the breaking change page of the ember-data source code but I am really confused as of what it is I need to look into.
For the Revision 5 (the revision I am trying to upgrade too I guess), there are so many things and none seems to really apply to my app.
So, someone might be able to provide me with some guidance as far as what's the methodology around upgrading revision. Do you need to address the revision notes and then up the revision number (then repeat) OR does it mean that something has been broken and you need to use that revision number for the time being?
Sorry about the lengthy post, but I am trying to get out of my own confusion :)
Thanks!

nice to see you're giving ember a shot!
So that error message works the other way around - it's complaining that you're revision (5) is too low for the version of ember-data.js. Ember is forcing you to manually update your rev number to match the one that is current. Ember-data library is changing so fast, they want to make everyone is aware of breaking changes. If you are building something new just set the revision to whatever is current (as of today that's 11)
That peepcode video was good but is way out of date. Trying to follow along while using current version of ember is not going to work. Ember has changed a lot in the last several weeks and most of the tutorials/etc you'll find online have not caught up. Right now the best source of info is the guides: http://emberjs.com/guides
Also I'd recommend watching Tom Dale and Yehuda Katz presentation at Seattle Ember.js meetup last month: http://www.youtube.com/watch?v=_6yMxU-_ARs

As Michael said the tutorial is a bit out of date. I updated to the actual version of the libs (jquery, handlebars, ember and ember-data). Current revision for DS is 12
App.Store = DS.Store.extend({
revision: 12,
adapter: 'DS.FixutreAdapter'
});

Related

Refactoring Computed Properties on Ember.js 1.13

I was able to upgrade most of my Ember.js project to 1.13 after having some issues along the way, but now I can't wrap my head around the following deprecated code:
filteredPosts: function(){...}.property('var1','var2','var3')
When I enable it, the only notice that I receive is:
Uncaught TypeError: controllerClass.proto is not a function.
Noting that ComputedPropertyPrototype.get is the only useful information coming from the Stack Trace.
After researching around, I only found this concerning the deprecation, so I wanted to know how such code would be refactored into the native array methods or into anything that allows the same behavior.
Also, my apologies as I unfortunately cannot post an extra link to the specific file due to being a new user, so if you want to see the complete project you can head to github.com/Deovandski/Fakktion.
filteredPosts: function(){...}.property('var1','var2','var3')
should become:
filteredPosts: Ember.computed('var1', 'var2', 'var3', function() {
...
});
It's because prototype extensions are discouraged in recent versions of Ember and seems like you've encountered a problem related to prototype extensions. It'd be best if you create a demo of this issue, but Ember.computed should just work.

ember js how to remove the hash tag in my url

I have seen an answer to this question and was directed to the Ember API Docs for using the browser's history.pushState ability
Apparently I need to add this code to my router.js file
App.Router.reopen({
location: 'auto'
});
However, doing so breaks my app! It is a very simple app so far, since I am still only learning... so its basically just a default installation with only 4 templates, 4 routes. I am using Ember App Kit which, I noticed initializes the router slightly differently than the ember guides describes.
Is there something different I need to do? or is there something I am doing wrong in general?
Ok... I found the answer, for anyone who might run into this same issue.
Ember app kit seems to define the router in a variable just called Router, so I don't need to use the conventional naming requirements.
All that needs to be added to the router.js is this:
Router.reopen({
location: 'auto'
});
:D

Getting Started with Ember-Model: Ember.Adapter subclasses must implement findAll

I've tried to follow along with the Ember cast video:
http://www.embercasts.com/episodes/getting-started-with-ember-model
I originally tried with the latest handlebars rc4 and ember rc6 but was receiving this error:Ember.Adapter subclasses must implement findAll
It doesn't make much sense because I can see the findAll method implementation defined in the fixture adapter source code. I tried debugging the app.js to check the App.Person.adapter but with all the gets and wrappers for mixins it wasn't very helpful.
Then I downloaded the source code from the video directly and opened the index.html in the browser and still have the same error. This was really strange since the code obviously worked for the video.
Anyways, I tried to make a jsFiddle here:
http://jsfiddle.net/YCG9b/1/
to see if someone could point out what I expect to be a trivial mistake somewhere.
jsFiddle didn't like loading ember-model.js from github so I pasted the whole thing into the JS section.
There is so little going on here that it seems this is likely an incompatibility between versions of libraries, some environmental thing, or a silly syntax error somewhere.
My understanding is that this line App.Person.adpater = Ember.FixtureAdapter.create(); somehow isn't actually putting an adapter with a findAll method on the person model, so the subsequent call of App.Person.find() is failing.
Quite embarrassing, but I misspelled adapter...
I even quoted the line of code that had the error. :(
App.Person.adapter = Ember.FixtureAdapter.create();
Anyways, here is the updated fiddle if anyone else finds this in the future:
http://jsfiddle.net/YCG9b/3/
It looks like you're mixing up Ember Model with Ember Data (they both fill the same model void). Ember data is provided by the ember core team, ember model is by Erik Bryn who also commits regularly to Ember. They are both really good.
Ember Data requires a store, and you use DS.attr and DS.Model.extend etc...
BTW, cdnjs has a ember data if you want to link it to your jsfiddle.
Here it is fixed up: http://jsfiddle.net/PX5DV/
App.Store = DS.Store.extend({
revision: 13,
adapter: DS.FixtureAdapter.create()
});
App.Person = DS.Model.extend({
id: DS.attr(),
name: DS.attr()
});

Ember.Controller doesn't exist?

I'm just getting started with Ember. I'm a little confused on some things, as the guides on the main site seem to indicate different ways of working.
In the main docs (http://emberjs.com/documentation/), it indicates that a controller should just extend an ordinary Ember object like this:
Ember.Object.extend();
Which works fine for me.
Then in the guide to using Routing (http://emberjs.com/guides/outlets/) it suggests that there is a Controller object type that you can extend:
Ember.Controller.extend();
This doesn't work for me, and if I simply try to console.log Ember.Controller, its undefined.
I'm using Ember version 0.9.8.1.
Should I worry about this, or should I just carry on with extending Objects as my controllers?
0.9.8.1 is aging, and unfortunately even the guides on the site are ahead of it -- use latest (at https://github.com/emberjs/ember.js/downloads) to keep up with the most current best practices.
Update: 1.0-pre is out (emberjs.com), so that is the best to use. The docs / guides have been brought up to date.
I think #pauldechov means the specific "latest" build which you can find here: https://github.com/emberjs/ember.js/downloads
But also keep in mind that the documentation and "latest" are not always in sync.

Router / StateManager - can't make it work

I've been trying to implement a router as specified in this guide, but I can't make it work. Can anyone give a quick code sample using the latest version of Ember to enable a router that supports routing through urls?
Here is a one with ember latest, still prone to changes :)
http://jsfiddle.net/C7LrM/86/ posted by #mediastuttgart
The comments section of this Gist by wycats looks like the place where you can get updated fiddles :) https://gist.github.com/2728699#comments
This example uses:
handlebars-1.0.0.beta.6.js
Ember latest as of now:
// Version: v0.9.8.1-484-g73ac0a4
// Last commit: 73ac0a4 (2012-07-06 11:52:32 -0700)
For documentation of present code under development please go to ember source where they have documentation alongside code,
Eg: https://github.com/emberjs/ember.js/blob/master/packages/ember-routing/lib/router.js
https://github.com/emberjs/ember.js/blob/master/packages/ember-routing/ in general