Ask A Question

Notifications

You’re not receiving notifications from this thread.

0 Using VueJS with Rails: Using VueJS for Nested Forms in Rails: Part 1

Chris Oliver asked in General

You show how to do russian doll caching on rails views, but how to do caching on vuejs template ?

Reply

Well you wouldn't because it's up to your Javascript to generate the views dynamically. You would just cache the JSON response server side and the browser will generate the html from scratch every time.

Reply
Stephen Miles MacLennan Stephen Miles MacLennan

Great vid Chris. You mention that you could serialize the players in team, but rails needs it as a "_attributes" for the strong params. How would you handle another level of nesting - ie: if players had shoes. You couldn't set aside a separate object (as each player has shoes), so I think you'd need to serialize it? How would you handle that with your method above?

Reply

In that situation, I would probably just leave the JSON alone, serialize it with the wrong names, and then at the very end go through and rename those properties. You could do that on either side as well, in the JS or in the controller. It wouldn't really matter, but it might be easiest to do in JS.

Reply

Can't find hello_vue.js in manifest.json error

Reply

Hi. I haven't watched the video, just sniped some code I needed. FYI, there's a typo: meta[name="csfr-token"] instead of csrf-token. Thanks!

Reply

Hah, good catch. Thanks for the heads up on that.

Reply

I wrote a gem to load vue file into rails asset pipe, without install webpack or browserify ...

https://github.com/kikyous/...

Reply
Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 81,149+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.

    Screencast tutorials to help you learn Ruby on Rails, Javascript, Hotwire, Turbo, Stimulus.js, PostgreSQL, MySQL, Ubuntu, and more.

    © 2024 GoRails, LLC. All rights reserved.