Where do I subclass SC.Record?

Posted by Jake on Stack Overflow See other posts from Stack Overflow or by Jake
Published on 2010-06-06T23:43:17Z Indexed on 2010/06/06 23:52 UTC
Read the original article Hit count: 414

Filed under:

I'm using SproutCore and going through the Todos tutorial on http://wiki.sproutcore.com/Todos+06-Building+with+Rails. SproutCore and Rails use different names for the primary key on a model (Sproutcore => 'guid', Rails => 'id').

The tutorial gives directions to Adjust Rails JSON output, but in my app that I'm planning on building, I cannot do this because sproutcore is only one of a couple interfaces used to interact with the Rails app. As an alternate option, the tutorial gives the following directions:

Option 2: Set primaryKey in your Sproutcore model class
You can subclass SC.Record and set the primaryKey of your sublcass to "id". Your Todo-
Object then needs to extend from e.g. App.Rails.Record.

App.Rails.Record = SC.Record.extend({
  primaryKey : "id" // Extend your records from App.Rails.Record instead of SC.Record.
});

Where should I subclass SC.Record (i.e. in what file) such that it is properly read and included?

© Stack Overflow or respective owner

Related posts about sproutcore