Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Vue on rails sample
<div id="user_info">
javascript_tag do
window.User = window.User || #{@json_from_controller_or_wherever.html_safe};
<!DOCTYPE html>
<script src=""></script>
<%= render "user_info" %>
<script src="./user_info.js"></script>
new Vue({
data() {
return {
user: {
first_name: '',
last_name: '',
template: `
<h1 v-text="fullName"></h1>
computed: {
fullName() {
return `${this.user.first_name} ${this.user.last_name}`
created() {
if (window.User) {
this.user = window.User
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.