THIS PROJECT DOES NOT WORK YET
Please note that
polymer-rails is very much an alpha project at this
point. You'll be living on the bleeding edge; pulling gems directly from
GitHub, fending off bugs, and dealing with half-implemented behaviors. That's
the joy of open source!
New Rails Projects
You can make use of the application template to quickly whip up new Polymer-enabled projects:
rails new -m https://raw.githubusercontent.com/nevir/polymer-rails/master/application-template.rb PROJECT
polymer-rails (and bleeding edge dependencies) to your
gem 'polymer-rails', git: 'https://github.com/nevir/polymer-rails' gem 'sprockets-htmlimports', git: 'https://github.com/nevir/sprockets-htmlimports'
Then initialize it via:
rails generate polymer:init
Before initializing your project, you may want to read on to understand the flags you can pass, and how they affect the project layout.
polymer-rails projects introduce a modified directory structure:
The bread and butter of your newly Polymerized app: all of your app's web components should be placed here.
Note that this directory is added to the Sprockets paths, so anything under it
is relative to the
/assets URL by default.
Third party components (managed by Bower) reside here.
To add a dependency, modify your
bower.json, and then run
In this new world of web components, you should find that very little code ends
polymer-rails combines your asset manifests into this single directory.
Or, if you would rather not combine your manifests,
polymer-rails will plunk
the HTML import manifests into
This is only performed for projects generated via the application template, or
--combine-manifests option of the
Like you should be used to with the other manifests, this file manages your
app-wide dependencies. Simply
<link href="..." rel="import"> any dependency,
and Sprockets will take care of the rest.
Note that there is currently no support for
require_tree style imports!
You'll have to import each component directly.
jQuery & Turbolinks Begone!
The DOM is sexy, you don't need no silly abstractions any more, right?
Projects generated via the application template do not include jQuery or
turbolinks. You can also use
--no-turbolinks to handle
this when running the
Ok, Now What? (Component Generator)
polymer-rails also includes a component generator to make your life easy:
rails generate polymer:component MyComponent
And, like any dutiful generator, it also allows for you to define a quick skeleton of your component by defining properties:
rails generate polymer:component BetterComponent foo:string bar:object
Hell, it even supports slim templates if you have
slim-rails (>= 2.1.5) installed!
Take a look at
for the options you can configure.