Created
June 9, 2017 05:11
-
-
Save gabytabs/989e34f16e40dc1f88ebea76f5316eda to your computer and use it in GitHub Desktop.
Revisions
-
gabytabs created this gist
Jun 9, 2017 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,13 @@ <%= content_tag :div, id: "post-index", data: { posts: @posts.to_json(except: [:id, :created_at, :updated_at]) } do %> <h1> Posts </h1> <div v-for="post in posts"> <h2>{{post.tweet}}</h2> </div> <% end %> This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,21 @@ import Vue from 'vue/dist/vue.js' import TurbolinksAdapter from 'vue-turbolinks' document.addEventListener('turbolinks:load', () => { var element = document.getElementById("post-index") if (element != null) { var posts = JSON.parse(element.dataset.posts) var post_index = new Vue({ el: element, mixins: [TurbolinksAdapter], data: function(){ return { posts: posts } } }) } }) This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,9 @@ class PostsController < ApplicationController # GET /posts # GET /posts.json def index @posts = Post.all end end