質問

In Rails, EmberJS hijacks your app/assets/javascripts directory. It doesn't have to go there, but that's the convention.

+ app
  + assets
    + javascripts
      + components
      + controllers
      + helpers
      + mixins
      + models
      + routes
      + templates
        + components
      + views
      - app.js
      - application.js
      - router.js
      - store.js

Let's say I want to use JavaScript MD5. Where do I add the file? What directory?

To use the EmberJS gem we also have to remove the require_tree directive. So we end up with this:

# application.js.coffee
#= require jquery
#= require jquery_ujs
#= require handlebars
#= require ember
#= require ember-data
#= require_self
#= require app

# for more details see: http://emberjs.com/guides/application/
window.App = Ember.Application.create()

# app.js.coffee
#= require ./store
#= require_tree ./models
#= require_tree ./controllers
#= require_tree ./views
#= require_tree ./helpers
#= require_tree ./components
#= require_tree ./templates
#= require_tree ./routes
#= require ./router
#= require_self
役に立ちましたか?

解決

Ember doesn't really hijack your JS folder. Simply put the code inside an "ember" folder to separate it from your own JS or other libraries you're using.

It should then look something like this (unsure about some of the ember files):

+ app
  + assets
    + javascripts
      + ember
        + components
        + controllers
        + helpers
        + mixins
        + models
        + routes
        + templates
          + components
        + views
      - app.js
      - router.js
      - store.js
    + jsmd5
      md5.js
    - application.js

Your application.js might look something like this:

# for more details see: http://emberjs.com/guides/application/
window.App = Ember.Application.create()

@import "jsmd5/md5.js"
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top