alchaplinsky / polymer-rails

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

Fresh install in new Rails 4 app.. 'Uncaught SyntaxError: Unexpected token :' #30

Closed pdai1y closed 9 years ago

pdai1y commented 9 years ago

Like the title says, decided to give this a swing and see how well it performs.

Generated a new Rails 4 app, added polymer-rails to my gem and ran a bundle install.

After adding the html_import_tag into my main layout and refreshing the page gives me the Syntax error in the web console.

Even tried comparing this with your example and everything matches up, though I noticed you had removed Spring from your Gemfile.

Any idea what I may be doing wrong here?

EDIT: You can reference the branch I made here: https://github.com/PDaily/Technician/tree/polytest

alchaplinsky commented 9 years ago

I've pulled you rails app from polytest branch, added html_import_tag 'application' and everything seems to work fine, no syntax errors. Can you reproduce that with completely new rails app?

pdai1y commented 9 years ago

Sorry I haven't gotten back to this. Had IRL things to handle.

So I've revisited this, and I've gotten it to render Polymer Scaffold.. kind of.

This relates to your polymer-core gem, and when I try to make a component which includes core components I receive the error:

Uncaught Error: You tried to use polymer without loading it first. To load polymer,

Which is related to https://github.com/alchapone/polymer-core-rails/issues/5

And to answer your question, yes I have tried with a fresh Rails app. At least to pull in the components from polymer core.

I might be missing something here, sadly the example app only uses custom components and nothing from the core to base my app off of.

nielsen commented 9 years ago

I'm having the same problem with 0.2.5 -- it looks like the gem is no longer pulling in webcomponents.js (the example app is using 0.2.4).

alchaplinsky commented 9 years ago

Example app works fine with 0.2.5, I've just updated it. @PDaily it has to be related to poymer-core-rails, it is more unstable and causes multiple issues.

Vitalijus commented 9 years ago

I'm having the same problem with 0.2.8. Error: You tried to use polymer without loading it first.

alchaplinsky commented 9 years ago

Make sure that polymer.js is the first script included into your page. This is the reason in 90% cases, why you get this error 'You tried to use polymer without loading it first'

Vitalijus commented 9 years ago

In your README paragraph "Creating a component" you are asking "Add your component to manifest file after requiring webcomponents". For me this part was misleading, because it says to add component-name after webcomponents in application.js: //= require polymer/webcomponents //= require component-name/component-name

That why it didn't worked for me. So I added component-name to components/application.html.erb and it works now: //= require polymer/polymer //= require component-name/component-name

alchaplinsky commented 9 years ago

Oh, yes. There was an error in readme (I might have introduced it during renaming platform to webcomponents). Sure you don't need to include webcomponents into your html manifest. First line should be //= require polymer/polymer