{"id":21322,"date":"2018-03-30T12:15:25","date_gmt":"2018-03-30T09:15:25","guid":{"rendered":"https:\/\/www.webcodegeeks.com\/?p=21322"},"modified":"2018-03-30T10:09:41","modified_gmt":"2018-03-30T07:09:41","slug":"vuejs-components-with-coffeescript-for-rails","status":"publish","type":"post","link":"https:\/\/www.webcodegeeks.com\/javascript\/vuejs-components-with-coffeescript-for-rails\/","title":{"rendered":"VueJS Components with CoffeeScript for Rails"},"content":{"rendered":"<p>The components aspect of VueJS is one of the most attractive features VueJS brings to your frontend development. It allows for composable, reusable, and protected scope code, styles, and HTML. Working with protected scopes is the smart way for implementing coherent systems. And with the added benefit of VueJS protecting your style\u2019s scope to only affect your specific component, you\u2019ll have far fewer headaches with styling your site.<\/p>\n<p>With Webpack support being added to Rails as of Rails 5.1, the ecosystem for documentation on getting started is fairly young and missing many scenarios. So I\u2019m proud to be able to introduce one of the first posts on implementing VueJS Components with CoffeeScript in Rails. This can save you a couple of days of learning the hard way and will likely help existing VueJS\/Rails developers to perhaps learn a few new tricks.<\/p>\n<p>We\u2019ll be continuing from where we left off in the last blog post, <a href=\"https:\/\/blog.codeship.com\/vuejs-as-a-frontend-for-rails\/\">VueJS as a Frontend for Rails<\/a>. If you\u2019d like a copy of the code state from that, here is the public GitHub repository for that: <a href=\"https:\/\/github.com\/danielpclark\/vue_example\/tree\/FirstBlogVersion\">danielpclark\/vue_example<\/a>.<\/p>\n<h2>Adding ERB Support for .vue Files<\/h2>\n<p>To allow Ruby code interpolation with <code>.vue.erb<\/code> files like we have in <code>.html.erb<\/code> files, we need to first add the <code>rails-erb-loader<\/code> package with yarn.<\/p>\n<pre class=\"brush:php\">yarn add rails-erb-loader<\/pre>\n<p>Next we need to update our configuration file for webpack at <code>config\/webpack\/loaders\/vue.js<\/code> and change these lines:<\/p>\n<pre class=\"brush:php\">module.exports = { \r\n  test: \/\\.vue(\\.erb)?$\/,\r\n  use: [{\r\n    loader: 'vue-loader',\r\n    options: { extractCSS }\r\n  }]  \r\n}<\/pre>\n<p>to this:<\/p>\n<pre class=\"brush:js\">module.exports = { \r\n  test: \/\\.vue(\\.erb)?$\/,\r\n  use: [{\r\n    loader: 'vue-loader',\r\n    options: { extractCSS }\r\n  },  \r\n  {\r\n    loader: 'rails-erb-loader',\r\n    options: {\r\n      runner: 'bin\/rails runner',\r\n      dependenciesRoot: '..\/app'\r\n    }\r\n  }]\r\n}<\/pre>\n<p>Now we can have our Vue component files evaluate Rails methods and objects if we append the <code>.erb<\/code> extension to our <code>.vue<\/code> files.<\/p>\n<h2>Moving VueJS Code into a Component<\/h2>\n<p>First we can move our form view from <code>app\/views\/documents\/_form.html.erb<\/code> to our new file <code>app\/javascript\/form-repository.vue.erb<\/code>.<\/p>\n<pre class=\"brush:xml\">&lt;% include ActionView::Helpers::FormOptionsHelper %&gt;\r\n\r\n&lt;template&gt;\r\n  &lt;div&gt;\r\n    &lt;label&gt;Subject&lt;\/label&gt;\r\n    &lt;input type=\"text\" v-model=\"document.subject\" \/&gt;\r\n\r\n    &lt;label&gt;State&lt;\/label&gt;\r\n    &lt;select v-model=\"document.state\"&gt;\r\n      &lt;%= options_for_select(Document.states.keys, \"concept\") %&gt;\r\n    &lt;\/select&gt;\r\n\r\n    &lt;label&gt;Body&lt;\/label&gt;\r\n    &lt;textarea v-model=\"document.body\"&gt;&lt;\/textarea&gt;\r\n\r\n    &lt;br \/&gt;\r\n\r\n    &lt;button v-on:click=\"Submit\"&gt;Submit&lt;\/button&gt;\r\n  &lt;\/div&gt;\r\n&lt;\/template&gt;\r\n\r\n&lt;style scoped&gt;\r\n  textarea {\r\n    rows: 20;\r\n    cols: 60;\r\n  }\r\n&lt;\/style&gt;<\/pre>\n<p>And we\u2019ll simplify the <code>_form.html.erb<\/code> page down to:<\/p>\n<pre class=\"brush:xml\">&lt;% content_for :head do -%&gt;\r\n  &lt;%= javascript_pack_tag 'documents' %&gt;\r\n&lt;% end -%&gt;\r\n\r\n&lt;div id=\"vue-app\"&gt;\r\n  &lt;form-document\r\n    v-bind:document=\"&lt;%= document.to_json(except: [:created_at, :updated_at]) %&gt;\"\r\n  &gt;\r\n  &lt;\/form-document&gt;\r\n&lt;\/div&gt;<\/pre>\n<p>Before we finish by moving our CoffeeScript code from <code>app\/javascript\/packs\/documents.coffee<\/code> into the same component file, let\u2019s go over some features of this change.<\/p>\n<p>The HTML is the same for the form, but we do need to additionally wrap it by a single HTML tag for the template section of the component. For the Rails form helper method <code>options_for_select<\/code>, we needed to include the module that defines it \u2014 <code>ActionView::Helpers::FormOptionsHelper<\/code> \u2014 directly from Rails on the first line.<\/p>\n<p>And one of the coolest things we\u2019ve done is moved the styles for the text area from the HTML into a style section that will only ever affect this component, as we\u2019ve used the <code>scoped<\/code> attribute for <code>style<\/code>.<\/p>\n<p>On the <code>_form.html.erb<\/code> partial page, we\u2019ve simplified the code greatly. The <code>form-document<\/code> is a component name we\u2019re about to define in the CoffeeScript file. The <code>v-bind:document<\/code> is a prop we\u2019re using to hand our document data directly to our component.<\/p>\n<p>Technically this particular technique is called a <a href=\"https:\/\/vuejs.org\/v2\/guide\/components.html#Non-Prop-Attributes\">non-prop<\/a> since there isn\u2019t a corresponding prop defined. But we\u2019ll treat it the same way as a prop for getting data to our component. If we were to try to implement accessing this data from an external source, we\u2019d have to use more complex techniques with props like sync and\/or emit, but that\u2019s far more work than what our use case requires. The <code>v-bind<\/code> evaluates what\u2019s on the right side of the equal sign to a JavaScript object for our non-prop prop.<\/p>\n<p>Since we\u2019ve also removed the <code>id<\/code> we formerly used for a Vue object to initiate on, we\u2019ll need to add that to the list of things we change. We\u2019ll be stripping our <code>app\/javascript\/packs\/documents.coffee<\/code> down to just the following.<\/p>\n<pre class=\"brush:js\">import Vue from 'vue\/dist\/vue.esm'\r\nimport TurbolinksAdapter from 'vue-turbolinks'\r\nimport VueResource from 'vue-resource'\r\nimport FormDocument from '..\/form-document.vue.erb'\r\n\r\nVue.use(VueResource)\r\nVue.use(TurbolinksAdapter)\r\n\r\nVue.component('form-document', FormDocument)\r\n\r\ndocument.addEventListener('turbolinks:load', -&gt;\r\n  Vue.http.headers.common['X-CSRF-Token'] = document\r\n    .querySelector('meta[name=\"csrf-token\"]')\r\n    .getAttribute('content')\r\n\r\n  element = document.getElementById 'vue-app'\r\n\r\n  if element?\r\n    app = new Vue(el: element)   \r\n)\r\n\r\nTurbolinks.dispatch(\"turbolinks:load\")<\/pre>\n<p>Here, our component is imported to a <code>FormDocument<\/code> object, and we make the component usable as a tag with the <code>Vue.component<\/code> method. This needs to be defined before the first use of <code>new Vue<\/code>, and any component used in a web page must be within HTML tags that an instance of <code>new Vue<\/code> refers to. Since we call <code>new Vue<\/code> with the id reference of <code>#vue-app<\/code>, the <code>div<\/code> tag in our HTML page is now our root for this Vue object. This allows us to use the <code>form-document<\/code> tag in it like we would any other HTML tag.<\/p>\n<p>Now let\u2019s look at what our CoffeeScript looks like when moved over to a component in <code>app\/javascript\/form-repository.vue.erb<\/code>.<\/p>\n<pre class=\"brush:js\">&lt;script lang=\"coffee\"&gt;\r\nexport default\r\n  props:\r\n    document:\r\n      type: Object\r\n      required: true\r\n  methods: Submit: -&gt;\r\n    ourDocument = @_props.document\r\n    if ourDocument.id == null\r\n      @$http # New action\r\n        .post '\/documents', document: @document\r\n        .then (response) -&gt;\r\n            Turbolinks.visit \"\/documents\/#{response.body.id}\"\r\n            return\r\n          (response) -&gt;\r\n            @errors = response.data.errors\r\n            return\r\n    else\r\n      @$http # Edit action\r\n        .put \"\/documents\/#{@document.id}\", document: @document\r\n        .then (response) -&gt;\r\n            Turbolinks.visit \"\/documents\/#{response.body.id}\"\r\n            return\r\n          (response) -&gt;\r\n            @errors = response.data.errors\r\n            return\r\n    return\r\n&lt;\/script&gt;<\/pre>\n<p>Now our VueJS component should be working in our site. Just run <code>rails s<\/code> and open your web browser to <code>localhost:3000\/documents<\/code>.<\/p>\n<blockquote><p>If at any time the changes aren\u2019t showing up in your browser, you need to refresh the browser\u2019s cache with a hard reload. In the Chromium browser you can do this with CTRL-SHIFT-R.<\/p><\/blockquote>\n<p>Here our use of <code>props<\/code> is a form of type checker. I highly encourage that you use this technique for all props as it will give you very helpful information should you not be getting the prop into your component as you expected. You can look into implementing further prop validations at <a href=\"https:\/\/vuejs.org\/v2\/guide\/components.html#Prop-Validation\">prop validations<\/a>.<\/p>\n<p>The <code>export default<\/code> line is a JavaSciprt feature that has the following code all included as the main object when you use the <code>import SomeName<br \/>\nfrom 'source_code'<\/code> to require it. The other difference in our code here is the <code>@_props.document<\/code> line. The <code>@_props<\/code> gives us direct access to the props passed in on <code>this._props<\/code>.<\/p>\n<p>And with that you now have the ability to easily create and add as many VueJS components as you want to your Rails site. Next, we\u2019ll look at how easy it is to just drop in the show resource for our Documents resource as a VueJS component.<\/p>\n<h2>Multiple Components Per Rails Resource<\/h2>\n<p>Because individual components use their own HTML style tag, you can include as many components in your source code and call them only where you want in your pages. So to change your show-resource for documents in your project, it\u2019s pretty simple. Add two lines near the beginning of your <code>app\/javascript\/packs\/documents.coffee<\/code> file:<\/p>\n<pre class=\"brush:js\">import ShowDocument from '..\/show-document.vue'\r\nVue.component('show-document', ShowDocument)<\/pre>\n<p>We\u2019ll be replacing the following HTML from <code>app\/views\/documents\/show.html.erb<\/code>:<\/p>\n<pre class=\"brush:xml\">&lt;p&gt;\r\n  &lt;strong&gt;Subject:&lt;\/strong&gt;\r\n  &lt;%= @document.subject %&gt;\r\n&lt;\/p&gt;\r\n\r\n&lt;p&gt;\r\n  &lt;strong&gt;Body:&lt;\/strong&gt;\r\n  &lt;%= @document.body %&gt;\r\n&lt;\/p&gt;\r\n\r\n&lt;p&gt;\r\n  &lt;strong&gt;State:&lt;\/strong&gt;\r\n  &lt;%= @document.state %&gt;\r\n&lt;\/p&gt;<\/pre>\n<p>with:<\/p>\n<pre class=\"brush:xml\">&lt;% content_for :head do -%&gt;\r\n  &lt;%= javascript_pack_tag 'documents' %&gt;\r\n&lt;% end -%&gt;\r\n\r\n&lt;div id=\"vue-app\"&gt;\r\n  &lt;show -document\r\n    v-bind:document=\"&lt;%= @document.to_json(except: [:created_at, :updated_at]) %&gt;\"\r\n  &gt;\r\n  &lt;\/show&gt;\r\n&lt;\/div&gt;<\/pre>\n<p>And write the component in <code>app\/javascript\/show-document.vue<\/code> as:<\/p>\n<pre class=\"brush:xml\">&lt;template&gt;\r\n  &lt;div&gt;\r\n    &lt;p&gt; \r\n      &lt;strong&gt;Subject:&lt;\/strong&gt;\r\n      {{ document.subject }}\r\n    &lt;\/p&gt;\r\n\r\n    &lt;p&gt; \r\n      &lt;strong&gt;Body:&lt;\/strong&gt;\r\n      {{ document.body }}\r\n    &lt;\/p&gt;\r\n\r\n    &lt;p&gt; \r\n      &lt;strong&gt;State:&lt;\/strong&gt;\r\n      {{ document.state }}\r\n    &lt;\/p&gt;\r\n  &lt;\/div&gt;\r\n&lt;\/template&gt;\r\n\r\n&lt;script lang=\"coffee\"&gt;\r\nexport default\r\n  props:\r\n    document:\r\n      type: Object\r\n      required: true\r\n&lt;\/script&gt;<\/pre>\n<p>Since we\u2019re not evaluating anything with Ruby in this component, we make the file extension <code>.vue<\/code>. We\u2019re still using our prop validation technique. And we\u2019re using Vue\u2019s interpolation braces to fill out our values for the view.<\/p>\n<p>Now that we have our show page converted to use VueJS, we can further build on it by including components within the component. This is a very useful technique for implementing a more dynamic comment system. Create your own comment components and include them in as many other components in your site as you\u2019d like.<\/p>\n<h2>Summary<\/h2>\n<p>Protecting the scope of what your code and styles have access to will make your code base a much more sane environment to work in. Both VueJS and CoffeeScript enforce a form of protected scope and help you write better code. With the problems we\u2019ve inherited from years of backwards compatibility in the frontend technology stack, it\u2019s really nice to work with technologies that help enforce good practices.<\/p>\n<p>We\u2019ve now covered enough to make working with VueJS in Rails a far more pleasant experience. There are still so many more possibilities that branch out from this foundation of what you can do with VueJS, including visually dynamic content. If you need to have an excellent frontend framework of sorts to work with, then I highly recommend you seriously consider VueJS and CoffeeScript.<\/p>\n<div class=\"attribution\">\n<table>\n<tbody>\n<tr>\n<td>Published on Web Code Geeks with permission by Daniel P. Clark, partner at our <a href=\"\/\/www.webcodegeeks.com\/join-us\/wcg\/\" target=\"_blank\" rel=\"noopener\">WCG program<\/a>. See the original article here: <a href=\"https:\/\/blog.codeship.com\/vuejs-components-with-coffeescript-for-rails\/\" target=\"_blank\" rel=\"noopener\">VueJS Components with CoffeeScript for Rails<\/a><\/p>\n<p>Opinions expressed by Web Code Geeks contributors are their own.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>The components aspect of VueJS is one of the most attractive features VueJS brings to your frontend development. It allows for composable, reusable, and protected scope code, styles, and HTML. Working with protected scopes is the smart way for implementing coherent systems. And with the added benefit of VueJS protecting your style\u2019s scope to only &hellip;<\/p>\n","protected":false},"author":146,"featured_media":4127,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[95,427],"class_list":["post-21322","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-javascript","tag-rails","tag-vue-js"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>VueJS Components with CoffeeScript for Rails - Web Code Geeks - 2026<\/title>\n<meta name=\"description\" content=\"The components aspect of VueJS is one of the most attractive features VueJS brings to your frontend development. It allows for composable, reusable, and\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.webcodegeeks.com\/javascript\/vuejs-components-with-coffeescript-for-rails\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"VueJS Components with CoffeeScript for Rails - Web Code Geeks - 2026\" \/>\n<meta property=\"og:description\" content=\"The components aspect of VueJS is one of the most attractive features VueJS brings to your frontend development. It allows for composable, reusable, and\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.webcodegeeks.com\/javascript\/vuejs-components-with-coffeescript-for-rails\/\" \/>\n<meta property=\"og:site_name\" content=\"Web Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/webcodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2018-03-30T09:15:25+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/04\/rubyonrails-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Daniel P. Clark\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@webcodegeeks\" \/>\n<meta name=\"twitter:site\" content=\"@webcodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Daniel P. Clark\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"9 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/vuejs-components-with-coffeescript-for-rails\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/vuejs-components-with-coffeescript-for-rails\/\"},\"author\":{\"name\":\"Daniel P. Clark\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/a79c83c57cba5d8a6e46462149890b5e\"},\"headline\":\"VueJS Components with CoffeeScript for Rails\",\"datePublished\":\"2018-03-30T09:15:25+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/vuejs-components-with-coffeescript-for-rails\/\"},\"wordCount\":1212,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/vuejs-components-with-coffeescript-for-rails\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/04\/rubyonrails-logo.jpg\",\"keywords\":[\"Rails\",\"Vue.js\"],\"articleSection\":[\"JavaScript\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.webcodegeeks.com\/javascript\/vuejs-components-with-coffeescript-for-rails\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/vuejs-components-with-coffeescript-for-rails\/\",\"url\":\"https:\/\/www.webcodegeeks.com\/javascript\/vuejs-components-with-coffeescript-for-rails\/\",\"name\":\"VueJS Components with CoffeeScript for Rails - Web Code Geeks - 2026\",\"isPartOf\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/vuejs-components-with-coffeescript-for-rails\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/vuejs-components-with-coffeescript-for-rails\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/04\/rubyonrails-logo.jpg\",\"datePublished\":\"2018-03-30T09:15:25+00:00\",\"description\":\"The components aspect of VueJS is one of the most attractive features VueJS brings to your frontend development. It allows for composable, reusable, and\",\"breadcrumb\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/vuejs-components-with-coffeescript-for-rails\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.webcodegeeks.com\/javascript\/vuejs-components-with-coffeescript-for-rails\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/vuejs-components-with-coffeescript-for-rails\/#primaryimage\",\"url\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/04\/rubyonrails-logo.jpg\",\"contentUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/04\/rubyonrails-logo.jpg\",\"width\":150,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/vuejs-components-with-coffeescript-for-rails\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.webcodegeeks.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"JavaScript\",\"item\":\"https:\/\/www.webcodegeeks.com\/category\/javascript\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"VueJS Components with CoffeeScript for Rails\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#website\",\"url\":\"https:\/\/www.webcodegeeks.com\/\",\"name\":\"Web Code Geeks\",\"description\":\"Web Developers Resource Center\",\"publisher\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.webcodegeeks.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\/\/www.webcodegeeks.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"contentUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/webcodegeeks\",\"https:\/\/x.com\/webcodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/a79c83c57cba5d8a6e46462149890b5e\",\"name\":\"Daniel P. Clark\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/2342ad14824a1064823dcec81641a12136a3492abae522e473ec723cbfb84bce?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/2342ad14824a1064823dcec81641a12136a3492abae522e473ec723cbfb84bce?s=96&d=mm&r=g\",\"caption\":\"Daniel P. Clark\"},\"description\":\"Daniel P. Clark is a freelance developer, as well as a Ruby and Rust enthusiast. He writes about Ruby on his personal site.\",\"url\":\"https:\/\/www.webcodegeeks.com\/author\/daniel-clark\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"VueJS Components with CoffeeScript for Rails - Web Code Geeks - 2026","description":"The components aspect of VueJS is one of the most attractive features VueJS brings to your frontend development. It allows for composable, reusable, and","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.webcodegeeks.com\/javascript\/vuejs-components-with-coffeescript-for-rails\/","og_locale":"en_US","og_type":"article","og_title":"VueJS Components with CoffeeScript for Rails - Web Code Geeks - 2026","og_description":"The components aspect of VueJS is one of the most attractive features VueJS brings to your frontend development. It allows for composable, reusable, and","og_url":"https:\/\/www.webcodegeeks.com\/javascript\/vuejs-components-with-coffeescript-for-rails\/","og_site_name":"Web Code Geeks","article_publisher":"https:\/\/www.facebook.com\/webcodegeeks","article_published_time":"2018-03-30T09:15:25+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/04\/rubyonrails-logo.jpg","type":"image\/jpeg"}],"author":"Daniel P. Clark","twitter_card":"summary_large_image","twitter_creator":"@webcodegeeks","twitter_site":"@webcodegeeks","twitter_misc":{"Written by":"Daniel P. Clark","Est. reading time":"9 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.webcodegeeks.com\/javascript\/vuejs-components-with-coffeescript-for-rails\/#article","isPartOf":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/vuejs-components-with-coffeescript-for-rails\/"},"author":{"name":"Daniel P. Clark","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/a79c83c57cba5d8a6e46462149890b5e"},"headline":"VueJS Components with CoffeeScript for Rails","datePublished":"2018-03-30T09:15:25+00:00","mainEntityOfPage":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/vuejs-components-with-coffeescript-for-rails\/"},"wordCount":1212,"commentCount":0,"publisher":{"@id":"https:\/\/www.webcodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/vuejs-components-with-coffeescript-for-rails\/#primaryimage"},"thumbnailUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/04\/rubyonrails-logo.jpg","keywords":["Rails","Vue.js"],"articleSection":["JavaScript"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.webcodegeeks.com\/javascript\/vuejs-components-with-coffeescript-for-rails\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.webcodegeeks.com\/javascript\/vuejs-components-with-coffeescript-for-rails\/","url":"https:\/\/www.webcodegeeks.com\/javascript\/vuejs-components-with-coffeescript-for-rails\/","name":"VueJS Components with CoffeeScript for Rails - Web Code Geeks - 2026","isPartOf":{"@id":"https:\/\/www.webcodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/vuejs-components-with-coffeescript-for-rails\/#primaryimage"},"image":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/vuejs-components-with-coffeescript-for-rails\/#primaryimage"},"thumbnailUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/04\/rubyonrails-logo.jpg","datePublished":"2018-03-30T09:15:25+00:00","description":"The components aspect of VueJS is one of the most attractive features VueJS brings to your frontend development. It allows for composable, reusable, and","breadcrumb":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/vuejs-components-with-coffeescript-for-rails\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.webcodegeeks.com\/javascript\/vuejs-components-with-coffeescript-for-rails\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/javascript\/vuejs-components-with-coffeescript-for-rails\/#primaryimage","url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/04\/rubyonrails-logo.jpg","contentUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/04\/rubyonrails-logo.jpg","width":150,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/www.webcodegeeks.com\/javascript\/vuejs-components-with-coffeescript-for-rails\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.webcodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"JavaScript","item":"https:\/\/www.webcodegeeks.com\/category\/javascript\/"},{"@type":"ListItem","position":3,"name":"VueJS Components with CoffeeScript for Rails"}]},{"@type":"WebSite","@id":"https:\/\/www.webcodegeeks.com\/#website","url":"https:\/\/www.webcodegeeks.com\/","name":"Web Code Geeks","description":"Web Developers Resource Center","publisher":{"@id":"https:\/\/www.webcodegeeks.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.webcodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.webcodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/www.webcodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/webcodegeeks","https:\/\/x.com\/webcodegeeks"]},{"@type":"Person","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/a79c83c57cba5d8a6e46462149890b5e","name":"Daniel P. Clark","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/2342ad14824a1064823dcec81641a12136a3492abae522e473ec723cbfb84bce?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/2342ad14824a1064823dcec81641a12136a3492abae522e473ec723cbfb84bce?s=96&d=mm&r=g","caption":"Daniel P. Clark"},"description":"Daniel P. Clark is a freelance developer, as well as a Ruby and Rust enthusiast. He writes about Ruby on his personal site.","url":"https:\/\/www.webcodegeeks.com\/author\/daniel-clark\/"}]}},"_links":{"self":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts\/21322","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/users\/146"}],"replies":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/comments?post=21322"}],"version-history":[{"count":0,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts\/21322\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/media\/4127"}],"wp:attachment":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/media?parent=21322"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/categories?post=21322"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/tags?post=21322"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}