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

Naming Collision with Rails' application.js #339

Open
p886 opened this issue Feb 10, 2014 · 4 comments
Open

Naming Collision with Rails' application.js #339

p886 opened this issue Feb 10, 2014 · 4 comments

Comments

@p886
Copy link

p886 commented Feb 10, 2014

The issue arises when you run rails generate ember:bootstrap in a rails project. Rails provides the application.js file which the sprockets gem uses as a manifest. The ember-rails gem bootstraps the application with a applications.js.coffee file which gets preprocessed to application.js. Thus we end up with two application.js files. Sprockets will only use one and it seems to choose the one which rails provided. This means the line window.EmberTest = Ember.Application.create() never gets run and window.EmberTest never gets defined and I'm getting the javascript error: Uncaught ReferenceError: AppName is not defined.

The workaround is to rename application.js.coffee to something else. When I renamed it to application_ember.js.coffee everything worked fine.

To see the bug in action I created a rails project in which you can see both the bug and the workaround. I haven't seen any mention of this naming collision so far. Did I do something wrong or is this really a bug?

Some stats:
Rails: v4.0.0
Ember-Rails: v.0.14.1
Ember-Source: v.1.3.0

@fmendez
Copy link

fmendez commented Mar 26, 2014

I was able to replicate this issue as well. It took me a while to figure out that it was a naming collision. My solution was also to rename the application.js.coffee to something else.

@scottfister
Copy link

I also had this issue. However I also experienced App is not defined and Ember is not defined errors also. I combined them into one file as I had to re-organise the import order of the application.js file so that require_tree was after Ember.

@stopachka
Copy link

Instead of of creating application.js.coffee, could we make that be the only non-coffeescript file, and instead append that data to application.js?

@liclac
Copy link

liclac commented Oct 19, 2014

Bump? This is rather easily solved (renaming application.js.coffee -> application_ember.js.coffee), but getting an error from running a generator feels rather silly.

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

No branches or pull requests

5 participants