ember.js - Can't find DS.Store instantiation in Ember application -


i have build small ui widget in ember.js using jsfiddle. works fine ember-data fixture adaptor wanted take local environment , thought i'd use brunch build environment me. since time i've wasted full day trying work , i'm hoping can me on hump. strong suspicion @ time remaining problem either namespace or sequencing issues arises out of common-js packaging brunch you. i'm quite new common-js may simple lack of understanding ... here's basic problem:

  • when run application , move activities template assertion failed: application not have 'store' property defined error.

my initialisation file looks this:

// namespace app = require('app'); // ===== router ===== app.router.map(function() {     this.resource('index', { path: '/' }, function() {});     this.resource('activities', { path: '/activities' }, function() {});     this.resource('hi', { path: '/hi' }, function() {});  }); // ===== routes ===== require('routes/activitiesroute');  // ===== store ===== require('stores/fixture');  // ===== models ===== require('models/activity');  // ===== views =====  // ===== controllers =====  require ('controllers/activitiescontroller');  // ===== template helpers ===== require('helpers/time');  // ===== templates ===== require ('templates/application'); require ('templates/hi'); require ('templates/activities'); 

a working example of code -- albeit without common-js , brunch -- can found in jsbin: http://jsbin.com/oyosev/56/edit. when running locally, loads index page , can navigate , forth between "hi" page , index without incident. problem happens when {{#linkto}} activities view/template/controller. activities -- of course -- view/controller backed model. understand it, flow starts activitiesroute:

app=require("app");  console.log("activitiesroute file loaded"); module.exports = app.activitiesroute = ember.route.extend({      init: function() {         console.log("activitesroute instantiated!");     },      model: function() {         return app.activity.find();     }  }); 

it instantiates object (as seen in following log file) tries load activity model , notices ... hey, haven't defined store yet. problem ... have or @ least have attempted to. reference purposes here console messages tell execution story:

console log

the first important thing notice initialisation script have included line: require('stores/fixtures'); should lead instantiation of ds.store stored in app.store property. here's fixtures.js file:

app = require("app");  console.log("store file loaded"); module.exports = app.store = ds.store.extend({     init:function() { console.log("store instantiated!"); },     revision: 13,     adapter: ds.fixtureadapter.create() }); 

you can see in console log (above) file indeed loaded init method should run on instantiation , never appears there wrong here i'm @ loss explain same exact syntax (with exception of common-js modules.export , require statements) working in fiddle.

any , appreciated.

-=-=-=-=- update -=-=-=-=-

i've added debugging line in init function of activitiesroute sends app object console inspection. i'm not expert on it's supposed feels strong clue local installation claims store (unknown mixin) when run in jsbin store reports app.store:

non-working local

enter image description here

ok, after pain have solved problem. largely down to:

  • duplicate files in /vendor/scripts

more details on how came pass , transient problem ran in process below:

duplicate files

  • i noticed -- when looking @ /vendor/scripts directory -- there 2 ember scripts (ember-latest , ember-1.0.rc.6). ironically 1 called rc.6 rc.5 build whereas ember-latest indeed rc.6. in either case, having 2 asking trouble.
  • because "ember-latest" file more current went , removed "rc.6" file.
  • this led transient error:
    • i had 1 ember file in vendor.js ember being compiled after ember-data
    • this called sorts of dependency problems aren't managed common-js (as in app.js file)
    • the config.coffee file manage sequencing that's when noticed referring "rc.6" file not "latest" file giving no instruction required sequencing between ember , ember-data. grrr.
    • easily fixed though, changed config.coffee reference , worked.
  • now that's great how did end 2 files in first place?
    • well brunch skeleton forked (brunch-with-ember-reloaded) has cakefile provides convenient way pull down latest ember , emberdata files: cake getember , cake getemberdata.
    • emberdata fine, creates file called ember-data-latest.js naming convention ember-data in directory.
    • getember, however, creates file called ember-latest.js original file aforementioned ember-1.0.rc.6 file.
    • so, in effect, automation in cakefile led duplicate file and newly downloaded ember code not target of brunch solution instead static "rc.6" file.

epilogue

i must i'm glad have problem out of way. if you're still reading along may interested know have made needed changes forked brunch skeleton. please note repo has been modified allow javascript coding instead of coffeescript , i've switched using less processor instead of stylus.

skeleton: brunch-with-ember-sideloaded


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -