honulife / rails-turbo-vue Goto Github PK
View Code? Open in Web Editor NEWA Rails 7 app that can use Vue to render parts of views on the client side
A Rails 7 app that can use Vue to render parts of views on the client side
Provide a step-by-step guided example of generating a scaffold and then replacing one of the views with a view that uses Vue.js
{
'/': [['#app-mount', App], ['#app-sidebar', Sidebar]]
}
<template>
, <script>
, and <style>
on the server in a .html.erb file but then use this and parse it on the fronted to add reactivity:
v-cloak
to prevent unprocessed Vue templates from appearing on the page.<!-- show.html.erb -->
<template>
<h1><%= model.name %></h1>
<button @click="doSomething">Click me!</button>
</template>
doSomething
function be defined in this case?Here's a rough idea based on my understanding so far
// hit an endpoint on the rails server that renders the `show.html.erb` _(see above)_
const res = await fetch('/model/show.html')
Vue.createApp({
template: await res.text(), // https://developer.mozilla.org/en-US/docs/Web/API/Response/text
// Something here to define the doSomething function?
})
<script>
tags with imports, etc within the .html.erb
file that is rendered and then processed by Vue
as the template
option passed to createApp
?Ex. Could I do this?
<!-- show.html.erb -->
<template>
<h1><%= model.name %></h1>
<button @click="doSomething">Click me!</button>
</template>
<script setup>
const doSomething = () => {
alert("Hello world!")
};
</script>
app/frontend/helpers/route-helper.ts
This could be handy in cases where a view already exists because it was already generated by something such as the scaffold generator.
If a person wants to just replace the index view with a view that uses Vue.js for part of its rendering, then they may not want to have a new route entry defined (since one already exists) or a new controller method (since that already exists too)
Splitting out the screenshot tests can allow this. It would also allow for independent scaling of the runner for the screenshot tests if those tests end up running slow compared with other RSpec tests.
The approach would involve having a new spec directory, something like spec/screenshot_specs
that could then be ignored when the rest of the RSpec suite is run. This could be done using the --pattern
cmd line arg
This will allow for a single testing DSL in the app (rspec tests + frontend component tests)
This helps in cases where a user is on a page with some stale JS and they load a page and it tries to fetch a Vue component that loads async but uses a state file name or path.
Use the manifest.json file that is output by Rollup to get the path/filename for the new Vue component and try to load that.
When a page loads, additional HTTP requests from Vue components should not need to be made to render the initial state of the page.
Hey, I've used this app as template for my own app. So far everything was great and smooth, but once I tried to deploy to prod server I'm getting 404 on any assets. The assets:precompile works great, and assets put into public/vite/assets
folder. However when opening app via browser, any assets on such url https://domain.com/vite/assets/application-d671fe8c.css
just returns 404. Any ideas where should I look at or what did I miss? I use Capistrano for deployment
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.