Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generator for resource #21

Closed
alexphys opened this issue Oct 14, 2014 · 9 comments · Fixed by #50
Closed

Generator for resource #21

alexphys opened this issue Oct 14, 2014 · 9 comments · Fixed by #50
Assignees
Labels

Comments

@alexphys
Copy link

When I run

ember generate resource ingredients.

I got an error saying

no such file or directory "path-to-app/my-app/app/router.js"

This happens only when I'm trying to generate a resource. When trying to generate a route all is working perfectly, a route is being added inside my router.coffee file and the route and template files are being generated perfectly as coffee.

Anyone else noticed this?

@kimroen
Copy link
Owner

kimroen commented Oct 14, 2014

Thank you for noticing this - it does actually look like generating resources doesn't work at all at the moment, they generate js-files either way, which then means it tries to add the route to router.js, which doesn't work because it doesn't exist.

I can think of a few ways of fixing this, so I'll take a look in not too long.

For now, generating the model and route separately would be the way to go. You can specify a resource when generating the route by running

ember g route myRoute --type=resource

Sorry about this.

@kimroen kimroen added the bug label Oct 14, 2014
@kimroen kimroen self-assigned this Oct 14, 2014
@alexphys
Copy link
Author

Thanks for your answer and effort on it!
Cheers!

@kimroen
Copy link
Owner

kimroen commented Oct 21, 2014

I looked in to this today, but unfortunately it doesn't look like I have the tools available to make this work again right now.

Ping @jgwhite - do you have any suggestions on making this work? Whatever I do, the resource generator uses the model and route blueprint from ember-cli, not the ones from ember-cli-coffeescript. Not defining it used to work (ember-cli would use these blueprints), but since a few versions ago this stopped working.

@jgwhite
Copy link

jgwhite commented Oct 21, 2014

In the ember-cli’s resource blueprint, Blueprint.lookup is called without addon lookup paths. It should look more like this:

_processBlueprint: function(type, name, options) {
  var mainBlueprint = Blueprint.lookup(name, {
    ui: this.ui,
    analytics: this.analytics,
    project: this.project,
    paths: this.project.blueprintLookupPaths() // <---
  });

  ...

To get ember-cli-coffeescript working quickly, I would suggest copying and fixing ember-cli’s resource blueprint.

Long term, I’m hoping to find time to add a Project#lookupBlueprint method and sunset Blueprint.lookup.

kimroen added a commit that referenced this issue Oct 21, 2014
@kimroen
Copy link
Owner

kimroen commented Oct 21, 2014

It looks like this.project is undefined here, so I won't be able to pass it in.

@kimroen
Copy link
Owner

kimroen commented Oct 21, 2014

Here's my attempt so far: https://github.com/kimroen/ember-cli-coffeescript/blob/fixing-resources-blueprint/blueprints/resource/index.js

A log of this inside the function yields this:

{ path: '/Users/kimroen/Utvikling/kimroen/ember-cli-coffeescript/blueprints/resource',
  name: 'resource' }

@nathanpalmer
Copy link

@kimroen You need to set the project within install

  install: function(options) {
    this.project = options.project;
    return this._process('install', options);
  },

@kimroen
Copy link
Owner

kimroen commented Jan 31, 2015

@nathanpalmer I could kiss you.

@kimroen
Copy link
Owner

kimroen commented Jan 31, 2015

This should work again now with ember-cli-coffeescript 0.8.0.

Not pretty - hopefully I can delete all this code again in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants