Google Polymer with rails 4

I have a Ruby on rails app. I want to use polymer with my ruby ​​on rails app. Does anyone offer some good resources for studying polymer with rails?

Is it effective to use a polymer with ruby ​​on rails? Please also suggest other options than polymer, if any?

+5
source share
5 answers

I use a gazebo, so I expect that you already have a bell setting in your system. (brew install node & npm install bower)

  • Customize your gems

    gem 'bower-rails' gem 'emcee' 
  • bundle install

  • rails g bower_rails:initialize

  • rails g emcee:install

  • Configure the bower file. Below is what my following looks like:

     asset 'angular' asset 'angular-route' asset 'angular-resource' asset 'angular-mocks' asset 'webcomponentsjs' asset 'polymer', github: 'Polymer/polymer' asset 'polymer-core-elements', github: 'Polymer/core-elements' asset 'polymer-paper-elements', github: 'Polymer/paper-elements' asset 'platform' # Voice Synthesis and Recognition asset 'voice-elements' 

    Find out the ones you need and delete the rest.

  • rake bower:install
    To download components, please note that the files will be stored in providers / assets / bower_components, not the suppliers / assets / components expected by emcee. Therefore, you will need to make a symbolic link.

  • Setting up symbolic links

    • first remove the components i.e. rm -rf vendor/assets/components
    • then configure the symbolic link ie ln -s vendor/assets/bower_components vendor/assets/components
  • Now set up your assets

     # app/assets/components/application.html *= require polymer/polymer # app/assets/javascripts/application.js //= require angular/angular //= require angular-route/angular-route //= require angular-resource/angular-resource //= require webcomponentsjs/webcomponents //= require platform/platform 

    (Note that I have included only everything that I use for testing. As stated above, remove the ones you don't need).

  • Just cleaning the house you jump to start sorting out. Incorporate Bower components on the road with a rake.

     # config/application.rb config.assets.paths << Rails.root.join("vendor","assets","bower_components") 

    And this applies to the installation. Jump on it and start using it.

  • Include html import tag in your layout file

     = html_import_tag "application", "data-turbolinks-track" => true 
  • And call the polymer sample in your opinion

     # sample.html.haml ================ %paper-tabs{:selected => "0", :scrollable => ""} %paper-tab Skills %paper-tab Experiences %paper-tab Education 

Link http://angular-rails.com/bootstrap.html http://www.akitaonrails.com/2014/06/29/usando-polymer-com-rails#.VHcoW2SsV81

+10
source

In a deep search on Google. I found that "emcee" is best used with rails. following options: -

Nevir / polymer rails

alchapone / polymer rails

ahuth / entertainer

also check- http://joshhuckabee.com/getting-started-polymer-ruby-rails

+2
source

I built a package of speakers for processing rail forms using polymer. This is very useful, especially if you are going to create any ajax forms or use nested attributes.

https://github.com/hobberwickey/polymer-rails-forms

To answer your more general question, though, I have been working with Polymer and Rails / Sinatra for a long time, and this is a great tool for creating the external interface of your application, without relying mainly on erb / haml or other server templates.

0
source

At first I tried to use web components with bower-rails and emcee .

But I noticed that bower-rails is not required, you just need to configure .bowerrc and bower.json, then run the bower installation.

In addition, emcee is no longer active, which forces you to use an older version of stars.

It turns out polymer-rails has the same functionality as emcee.

Here is my current setup

Gemfile

 gem 'polymer-rails' 

set and initialize

 bundle install rails g polymer:install 

application / views / layouts / application.html.erb

 <html> <head> ... <%= html_import_tag 'application'%> ... 

Download the bower.json file from elements.polymer-project.org and put it in the root of your application, then run the command

 bower install 

Your components should now be in the supplier / assets / components. Locate all .html files to include in the manifest. Some of the .html files are not the same name as the directory, so it is a little tedious.

Application / assets / components / application.html.erb

 //= require polymer/polymer //= require paper-scroll-header-panel/paper-scroll-header-panel //= require paper-toolbar/paper-toolbar //= require paper-tabs/paper-tabs //= require paper-drawer-panel/paper-drawer-panel //= require paper-icon-button/paper-icon-button //= require iron-icons/iron-icons //= require paper-card/paper-card //= require paper-button/paper-button ... 

Now make sure the stars are loading assets

configurations / Initializers / assets.rb

 Rails.application.config.assets.paths << Rails.root.join('vendor', 'assets', 'components', '*') 

Here is an example using the component

 <paper-card heading="Paper Card Example" image="<%= image_path 'example.jpg' %>"> <div class="card-content">This is an example of cards with polymer</div> <div class="card-actions"> <paper-button raised>OK</paper-button> </div> </paper-card> 

You can use polymer rail elements that already have many components, and you can skip the bower.json, bower install, and load assets settings. The only problem was that it was difficult for me to find out which ones were required, and some components were missing (e.g. google-apis). Hope this helps anyone trying to use polymer with rails!

0
source

Source: https://habr.com/ru/post/1206706/


All Articles