Skip to content

chrisvfritz/rails-javascript-integrations

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Pure Sprockets with Vue

This version uses the Rails asset pipeline, plain ES5 JavaScript, the jQuery that ships with Rails, and Vue.js to make componentization much simpler.

Setup

Less than 1 minute using vuejs-templates/simple as a reference.

Usage

Just launch Rails normally:

rails server

Pros

  • (Almost) zero setup: Beyond our one JS file, we also add a dependency in our application layout and add a line to application.js (there's also a vuejs-rails gem for simple asset pipeline integration)
  • Plain ES5: no Babel or CoffeeScript required, though CoffeeScript support also comes out of the box
  • Progressive: The parts of the app that have to be smart are, but everything else is just regular HTML
  • Really simple scoping: No extra classes, just custom elements
  • Plays well with jQuery: If you have existing UI controlled by jQuery, Vue won't freak out and break like React does
  • jQuery UJS: Rails' builtin jQuery UJS automatically sends the authenticity token in the header of jQuery's web requests
  • Less thinking: Using a simple component framework, there's a clear place for everything and a clear strategy for tackling any problem
  • Minimized boilerplate: The template reads easily and clearly describes what the component does, even for people who don't understand JavaScript

Cons

  • Still kinda ugly HTML: No HTML syntax highlighting and we have to use a lot of backslashes to escape the multiline string
  • Requires a little learning: A few hours with the excellent Vue docs is recommended to be optimally productive

About

Progressive integration strategies for JavaScript-heavy Rails apps

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published