I am using the latest canary build of Emberjs-1.0.0 and Ember-data 1.0.0-beta-2 on a rails-4 app. When I use this jsfiddle with the exact code in emberjs app from the rails app, no error is thrown, but when I start the rails app and try to go to the index page of the ember-app, it will throw the error Uncaught TypeError: Object [object Object] has no method 'applyPartial'
Nothing else is mentioned making it hard to debug or pin down the exact issue. I have removed turbo-links, so it is not a factor here.
Based on the uncaught exception thrown, it boils down to this line in emberjs https://github.com/emberjs/ember.js/blob/8624e8513a8db0294856cd3f559127dd7a7820b3/packages/ember-runtime/lib/system/core_object.js#L147
Class.PrototypeMixin.applyPartial(Class.prototype);
This screenshots are based on the emberjs-app not loading from within a rails-4 app
A screenshot of the callstack, here is shows superclass as Store, other times it shows unknownMixin
@Jeremy here is the full list of tags that appear in my page after rendering. I got this via view page source I have ran rake tmp:clear rake assets:clean, but the problem is still there
<script src="/assets/jquery.js?body=1"></script>
<script src="/assets/jquery_ujs.js?body=1"></script>
<script src="/assets/handlebars.js?body=1"></script>
<script src="/assets/ember.js?body=1"></script>
<script src="/assets/ember-data.js?body=1"></script>
<script src="/assets/application.js?body=1"></script>
<script src="/assets/store.js?body=1"></script>
<script src="/assets/models/users.js?body=1"></script>
<script src="/assets/controllers/application_controller.js?body=1"></script>
<script src="/assets/controllers/login_controller.js?body=1"></script>
<script src="/assets/controllers/signup_controller.js?body=1"></script>
<script src="/assets/controllers/user_controller.js?body=1"></script>
<script src="/assets/controllers/user_edit_controller.js?body=1"></script>
<script src="/assets/controllers/users_controller.js?body=1"></script>
<script src="/assets/templates/application.js?body=1"></script>
<script src="/assets/templates/index.js?body=1"></script>
<script src="/assets/templates/login.js?body=1"></script>
<script src="/assets/templates/signup.js?body=1"></script>
<script src="/assets/templates/user.js?body=1"></script>
<script src="/assets/templates/user/edit.js?body=1"></script>
<script src="/assets/templates/user/index.js?body=1"></script>
<script src="/assets/templates/users.js?body=1"></script>
<script src="/assets/templates/users/index.js?body=1"></script>
<script src="/assets/router.js?body=1"></script>
<script src="/assets/routes/application_route.js?body=1"></script>
<script src="/assets/routes/authenticated_route.js?body=1"></script>
<script src="/assets/routes/login_route.js?body=1"></script>
<script src="/assets/routes/signup_route.js?body=1"></script>
<script src="/assets/routes/user/edit_route.js?body=1"></script>
<script src="/assets/routes/user/index_route.js?body=1"></script>
<script src="/assets/routes/user_route.js?body=1"></script>
<script src="/assets/routes/users/index_route.js?body=1"></script>
<script src="/assets/routes/users_route.js?body=1"></script>
<script src="/assets/app.js?body=1"></script>
<script src="/assets/lib/development/ember-data.js?body=1"></script>
<script src="/assets/lib/development/ember.js?body=1"></script>
<script src="/assets/lib/production/ember-data.js?body=1"></script>
<script src="/assets/lib/production/ember.js?body=1"></script>
<script src="/assets/note_books.js?body=1"></script>
<script src="/assets/notes.js?body=1"></script>
Since you have ember-rails
in your Gemfile
you're probably getting the version of Ember that it provides, not the one that lives in app/assets/javascripts/lib/development
. You can load /assets/ember.js
in your browser to verify. If you want to make sure you get your custom version you should use this in application.js
//= require lib/development/ember
Alternatively to be extra sure, you could remove ember from application.js
completely and include the latest canary ember directly in your layout.
<script type='text/javascript' src="http://builds.emberjs.com/canary/ember.js"></script>
[UPDATE] : OK, the problem is that you're including ember.js multiple times (and possibly with multiple versions). I missed it when you first posted your bit list of script tags, but if you look at that closely you'll see that Ember and Ember Data are included at the top (lines 4 and 5 of the scripts), and then they're each included two mored times at the bottom.
...
<script src="/assets/ember.js?body=1"></script>
<script src="/assets/ember-data.js?body=1"></script>
...
<script src="/assets/lib/development/ember-data.js?body=1"></script>
<script src="/assets/lib/development/ember.js?body=1"></script>
<script src="/assets/lib/production/ember-data.js?body=1"></script>
<script src="/assets/lib/production/ember.js?body=1"></script>
...
My guess is that application.js
is requiring ember once on purpose with
//= require ember
And then it's getting picked up again with a require_tree
//= require_tree .
Usually you want to store external libraries (code that you do not personally maintain) in the vendor
directory of your app. This would allow to still use require_tree
to get all of your own javascript included in one shot. In my project that uses ember-rails
my structure looks like this:
app
assets
javascripts
# All my own stuff goes here
vendor
assets
ember
development
ember.js
ember-data.js
production
ember.js
ember-data.js
ember-rails
will find the versions in vendor
if you just use require ember
in application.js
. You'll want to make sure that you set config.ember.variant
in each of your config/environments/*.rb
files. For instance in config/environments/development.rb
you'll need to add this :
config.ember.variant = :development