alchaplinsky / polymer-rails

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

2 Uncaught TypeError using google-map #55

Closed enriquemorenotent closed 9 years ago

enriquemorenotent commented 9 years ago

I wanted to user this element on my website

https://elements.polymer-project.org/elements/google-map

so I installed it with bower

bower install --save GoogleWebComponents/google-map

and added it to my application.html

// This is a manifest file that'll be compiled into application.html, which will include all the files // listed below. // // Any web component HTML file within this directory or vendor/assets/components, if any, // can be referenced here using a relative path. // //= require polymer/polymer //= require google-map/google-map

Now when I use it, like this:

<style>
  google-map {
    height: 600px;
  }
</style>

<google-map latitude="37.77493" longitude="-122.41942"></google-map>

I get this errors on the console

Uncaught TypeError: Cannot read property '_notifyEffect' of undefined Uncaught TypeError: Cannot read property '_importsLoaded' of undefined

Did I miss a step here?

alchaplinsky commented 9 years ago

Which version of polymer-rails ?

enriquemorenotent commented 9 years ago

In my Gemfile I have

gem 'polymer-rails'

So I guess the last one. In any case, I fixed it by removing the line that was added in application.js (Which by the way, is not //= require webcomponentsjs/webcomponents-lite as the README says)

enriquemorenotent commented 9 years ago

Well, I figured out why it was not working.... The folder vendor/assets/javascripts/is empty! Should it be hosting webcomponents-lite.js?? Why is that not there after running rails g polymer:install?

alchaplinsky commented 9 years ago

vendor/assets/javascripts/ should not be hosting webcomponents-lite.js. This file is in gem assets folder.

enriquemorenotent commented 9 years ago

Then how come my application.js cant find it either way?

alchaplinsky commented 9 years ago

It depends on you app setup and code... Try to look into the output of Rails.application.config.assets.paths in rails console.

enriquemorenotent commented 9 years ago

What should I be looking for there? There are many entries..

alchaplinsky commented 9 years ago

for something like gems/polymer-rails-1.0.x/app/assets/javascripts

enriquemorenotent commented 9 years ago

In the path list I only have gems/polymer-rails-0.2.8/app/assets/javascripts, even though in the gems folder I have installed 0.2.2, 0.2.8, and 1.0.0...

enriquemorenotent commented 9 years ago

Could it have anything to do with the fact that I first tried to install the gem, but then I got an error because I had to update Sprockets to a version < 3.0...?

alchaplinsky commented 9 years ago

So, you're using old version of gem, which did not have webcomponents-js yet. Update to v1.0.x

enriquemorenotent commented 9 years ago

As you can see, I have it installed. The folder is there. It is just not in the paths. How do I fix that?

alchaplinsky commented 9 years ago

Look into Gemfile.lock which version of polymer-rails is intalled in your project?

enriquemorenotent commented 9 years ago

Doing bundle update fixed all. I wonder why it was not working from the beginning. In any case, thanks! :)

alchaplinsky commented 9 years ago

That's because you need specify version of gem in your Gemfile – gem 'polymer-rails', '1.0.8' And of course use latest version