tower-archive / tower

UNMAINTAINED - Small components for building apps, manipulating data, and automating a distributed infrastructure.
http://tower.github.io
MIT License
1.79k stars 120 forks source link

App.UsersIndexView:ember479 - Unable to find template "users/index" #335

Closed pashaie closed 12 years ago

pashaie commented 12 years ago

With tower version 0.4.2-14, mongodb 2.0.6 and nodejs v0.8.11 on Win7 64bit, I get following error:

Uncaught Error: App.UsersIndexView:ember479 - Unable to find template "users/index". Ember.View.Ember.Object.extend.templateForName ember.js:12078 Ember.View.Ember.Object.extend.template ember.js:12026 ComputedPropertyPrototype.get ember.js:2949 get ember.js:1355 Ember.View.Ember.Object.extend.render ember.js:12348 Ember.View.Ember.Object.extend.renderToBuffer ember.js:13017 Ember.View.Ember.Object.extend.createElement ember.js:12814 Ember.View.states.preRender.insertElement ember.js:13702 Ember.View.Ember.Object.extend.invokeForState ember.js:12384 invoke ember.js:3377 iter ember.js:3424 RunLoop.flush ember.js:3480 RunLoop.end ember.js:3396 Ember.run.end ember.js:3588 autorun

step used to create app:

Though i used start cake watch to start cake in new console. The node console isn't reporting any errors. But chrome console reports mentioned error. Same thing happens in Firefox 14. But in IE9 things are somewhat worse! There is much more errors.

SCRIPT5007: Unable to get value of the property 'replace': object is null or undefined tower.js, line 10042 character 3 SCRIPT5007: Unable to get value of the property 'draw': object is null or undefined routes.js, line 3 character 3 SCRIPT5007: Unable to get value of the property 'extend': object is null or undefined applicationController.js, line 4 character 5 SCRIPT5007: Unable to get value of the property 'cache': object is null or undefined templates.js, line 2 character 1 SCRIPT5007: Unable to get value of the property 'replace': object is null or undefined post.js, line 27 character 5 SCRIPT5007: Unable to get value of the property 'extend': object is null or undefined postsController.js, line 8 character 5 SCRIPT5007: Unable to get value of the property 'replace': object is null or undefined user.js, line 27 character 5 SCRIPT5007: Unable to get value of the property '__extend': object is null or undefined usersController.js, line 8 character 5 SCRIPT5007: Unable to get value of the property 'load': object is null or undefined bootstrap.js, line 5 character 7

lancejpollard commented 12 years ago

For the users/index issue, check the Tower.View.cache and Ember.TEMPLATES objects and copy/paste the keys into a comment here, the paths may be using windows vs. mac in one place:

console.log(_.keys(Tower.View.cache), _.keys(Ember.TEMPLATES));
pashaie commented 12 years ago

@viatropos, running that command in chrome console, result was ["application"] ["application"]

pashaie commented 12 years ago

I noticed that app\public\javascripts\app\templates\client folder has only index.js. I'm new to Nodejs or even Tower and Ember, but isn't it necessary to have app\app\templates\shared\posts and app\app\templates\shared\users folders there with it's content compiled from coffescript to javascript?

lancejpollard commented 12 years ago

The way templates are being compiled currently, they are just being written to 1 file:

app/public/javascripts/templates.js

That occurs within this grunt helper:

packages/tower-tasks/tasks/index.coffee#L15

Inside the generated templates.js you should find the compiled templates, so it looks something like this:

Tower.View.cache = {
  // lots of other templates...
  'posts/index': Ember.Handlebars.compile('...'),
  'welcome': Ember.Handlebars.compile('<h1>Welcome to Tower.js</h1>')
};

_.extend(Ember.TEMPLATES, Tower.View.cache);

The complete templates.js, from a newly generated app with a scaffolded Post model looks like this:

https://gist.github.com/3854729

What do you have inside that file? Copy/paste the whole thing into a gist and link it here, that would help. Thanks!

lancejpollard commented 12 years ago

Also paste the output from cake watch, this is mine:

$ cake watch
Default database not set, using Memory store
Running "copy:js" (copy) task
Copied 35 files.

Running "copy:css" (copy) task
Copied 2 files.

Running "coffee:all" (coffee) task

Running "less:bootstrap" (less) task
File public/stylesheets/vendor/stylesheets/bootstrap/bootstrap.css created.

Running "stylus:compile" (stylus) task
File public/stylesheets/app/stylesheets/client/application.css created.

Running "templates:all" (templates) task

Running "watch" task
Waiting...
thehydroimpulse commented 12 years ago

cake watch

C:\Users\Daniel\Documents\Projects\TestingTowerApplication>cake watch
path.existsSync is now called `fs.existsSync`.
Default database not set, using Memory store
Running "copy:js" (copy) task
Copied 35 files.
Running "copy:css" (copy) task

Copied 2 files.

Running "coffee:all" (coffee) task

Running "less:bootstrap" (less) task

Running "stylus:compile" (stylus) task
File 'public/stylesheets/app/stylesheets/client/application.css' created.

Running "templates:all" (templates) task

Running "watch" task
Waiting...
console.log(_.keys(Tower.View.cache), _.keys(Ember.TEMPLATES));

and I get:

["application"] ["application"] 

In public/javascripts/templates.js I get:

Tower.View.cache = _.extend(Ember.TEMPLATES, Tower.View.cache);
thehydroimpulse commented 12 years ago

I also quickly browsed the task file and specifically the template task and didn't see any OS specific paths or anything, though I didn't spend much time looking.

lancejpollard commented 12 years ago

That's probably it then, the value of Tower.pathSeparatorEscaped on windows should be the string '\\\\', which when passed into new RegExp in packages/tower-tasks/tasks/index.coffee#L22-35 should be:

pathSeparatorEscaped = Tower.pathSeparatorEscaped

templatePath = new RegExp("app#{pathSeparatorEscaped}templates#{pathSeparatorEscaped}.+\.coffee$")
# on mac with pathSeparatorEscaped == '/'
console.log(templatePath)
/app/templates/.+.coffee$/
# on windows with pathSeparatorEscaped == '\\\\'
/app\\templates\\.+.coffee$/

What are the values there if you log result and the patterns just after that for loop?

# just after loop
console.log(result)
console.log(templatePath, layoutPath, namePattern)

It could also be packages/tower-tasks/tasks/index.coffee#L19:

# maybe grunt's file.expand only understands `/` for paths?
files   = grunt.file.expand(["app#{_path.sep}templates#{_path.sep}**#{_path.sep}*.coffee"])

What is the value of console.log(files) after that line?

thehydroimpulse commented 12 years ago

This is what I get:

[] # result
/app\\templates\\.+.coffee$/ /layout\\application/ /app\\templates\\(?:client|shared)\\/

pathSeparatorEscaped does equal \\

console.log(templatePath + "\n")
console.log(layoutPath + "\n")
console.log(namePattern + "\n")

Returns: (Just to be clear)

/app\\templates\\.+.coffee$/
/layout\\application/
/app\\templates\\(?:client|shared)\\/

files equals:

[ 'app/templates/server/layout/application.coffee',
  'app/templates/server/layout/_meta.coffee',
  'app/templates/shared/layout/_body.coffee',
  'app/templates/shared/layout/_flash.coffee',
  'app/templates/shared/layout/_footer.coffee',
  'app/templates/shared/layout/_header.coffee',
  'app/templates/shared/layout/_navigation.coffee',
  'app/templates/shared/layout/_sidebar.coffee',
  'app/templates/shared/posts/edit.coffee',
  'app/templates/shared/posts/index.coffee',
  'app/templates/shared/posts/new.coffee',
  'app/templates/shared/posts/show.coffee',
  'app/templates/shared/posts/_flash.coffee',
  'app/templates/shared/posts/_form.coffee',
  'app/templates/shared/posts/_item.coffee',
  'app/templates/shared/posts/_list.coffee',
  'app/templates/shared/posts/_table.coffee',
  'app/templates/shared/users/edit.coffee',
  'app/templates/shared/users/index.coffee',
  'app/templates/shared/users/new.coffee',
  'app/templates/shared/users/show.coffee',
  'app/templates/shared/users/_flash.coffee',
  'app/templates/shared/users/_form.coffee',
  'app/templates/shared/users/_item.coffee',
  'app/templates/shared/users/_list.coffee',
  'app/templates/shared/users/_table.coffee',
  'app/templates/shared/welcome.coffee' ]

So that's all good.

Also when printing (in the loop):

for file in files
   console.log file

Returns every second output to null. Though this isn't a problem as it won't match the regex, but I thought i'd point it out.

lancejpollard commented 12 years ago

That's it then, grunt returns nice path's for us :), didn't realize that. So we don't need to use the path separator here, so templatePath should be /app\/templates\/.+.coffee$/ for both windows and mac.

Will fix in a bit unless y'all get to it first.

thehydroimpulse commented 12 years ago

Ok so that fixes the empty result but it seems like extra folders after app/templates/shared/ is erased. For example, app/templates/shared/layout/_flash.coffee actually turns into app/templates/shared/_flash.coffee.

lancejpollard commented 12 years ago

Not sure what you mean?

thehydroimpulse commented 12 years ago

yup all fixed!

thehydroimpulse commented 12 years ago

This may of be the last issue with windows....

pashaie commented 12 years ago

Thanks guys. But how can I rebuild templates? Restarting cake watch and server didn't work. grunt templates caused <FATAL> Unable to find "grunt.js" config file. Do you need any --help? </FATAL> I even tried npm install :D

lancejpollard commented 12 years ago

That could be because it was initially doing:

grunt watch --config ./grunt.coffee

but from my knowledge ./<path> doesn't work on windows (prefix with ./). So it's been changed to

grunt watch --config /full/path/to/grunt.coffee

Try replacing your cakefile with the new one here and let me know how that goes:

packages/tower-generator/server/generators/tower/app/templates/cake

thehydroimpulse commented 12 years ago

It fully works on my side so it may not be a windows problem (Sometimes the ./ works and sometimes it doesn't on windows... unreliable...)

lancejpollard commented 12 years ago

@pashaie also, what's the value of grunt --version, mine is:

$ grunt --version
grunt v0.3.15

It could also be an issue with grunt versions.

lancejpollard commented 12 years ago

@TheHydroImpulse does the full path change (copy/pasting the new Cakefile) work for you on windows?

thehydroimpulse commented 12 years ago

Both work.

pashaie commented 12 years ago

@viatropos actually using --config ./grunt.coffee worked. but running grunt templates --config ./grunt.coffee still template file (app\public\javascripts\templates.js) only contains Tower.View.cache = _.extend(Ember.TEMPLATES, Tower.View.cache); though I've edited app\node_modules\tower\packages\tower-tasks\tasks\index.coffee#22 to pathSeparator = '/'

btw, my grunt version is grunt v0.3.16

thehydroimpulse commented 12 years ago

@pashaie Did you update Tower? There were a few fixes in the tasks file to make it work. Try (within your app) removing tower npm rm tower and then reinstalling everything npm install. That should get you the latest fixes.

pashaie commented 12 years ago

@TheHydroImpulse thanks, it worked! @viatropos I didn't replace packages/tower-generator/server/generators/tower/app/templates/cake so, may be that wasn't necessary. Thanks. I really appreciate that.