alchaplinsky / polymer-rails

Polymer and web components for Ruby on Rails
MIT License
286 stars 80 forks source link

Uncaught TypeError: undefined is not a function -- prototype.registerCallback(); #50

Closed Nulubez closed 9 years ago

Nulubez commented 9 years ago

Hi,

I've been using polymer-rails for polymer 0.5 for a while, and it's been working flawlessly. When I tried to migrate to the newest version however, this error popped up. After spending some time troubleshooting, I decided to test the newest version of polymer-rails on a new rails app.

All I've done in this app is:

  1. Added polymer-rails to the gemfile. (v1.0.3)
  2. $ bundle install.
  3. $ rails g polymer:install
  4. $ rails g polymer:component test-component
  5. $ rails g controller Test test
  6. Added to my view.
  7. Added <%= html_import_tag 'application'%> to application layout.
  8. Required test-component/test-component in component manifest.

In my view, my component should show up, but instead I get the error "Uncaught TypeError: undefined is not a function" which points to prototype.registerCallback(). I thought that perhaps I'm supposed to install polymer manually, but still no luck.

What am I missing here? I know it's going to be something completely obvious once it's pointed out, but I can't seem to make any headway.

alchaplinsky commented 9 years ago

in your component you should use newer syntax for intializing webcomponent:

+Polymer({
+  is: "<%= component_name %>"
 });

And polymer-rails generator was fixed in #49

Nulubez commented 9 years ago

What? I'm supposed to follow the very first step in the migration guide? That seems way too complex a task for someone attempting to migrate to the newest version.

But seriously, thanks so much. I knew it'd end up being something like this. While trying to figure this out, I updated ruby, rails, and all dependencies, so it wasn't totally worthless.

One thing to note, however, is that if I don't specify the version like this:

gem 'polymer-rails', '>=1.0.0'

in my gemfile, then bundle installs the 0.2.8 version. Not sure if that's meant to happen since so many people are still on 0.5 polymer or what.

Here are some notes, just in case some future Googler hits a similar snag: Make certain to update rails and ruby to the latest version. Not certain if necessary, but it can't hurt. Check your gem version and make certain you're not on 0.2.8 *If you get "Bundler could not find compatible versions for gem "sprockets" error, try $bundle update instead of $bundle install.