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

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
Martynas ·

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

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.

Martynas ·

If for example using Active Model Serializer, I have view with many dynamic parts in a view. So I was wondering if its better make one request and have all required information than many small single requests. Is it possible to cache ?

From docs There is currently a problem with caching in AMS Caching doesn't improve performance.
https://github.com/rails-ap...

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?

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.

Stephen Miles MacLennan ·

Awesome thanks Chris, will try that! Great vid again, love your stuff :)

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

Erik Ostrom ·

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!

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

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

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

Join the discussion

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

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

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

    logo Created with Sketch.

    Ruby on Rails tutorials, guides, and screencasts for web developers learning Ruby, Rails, Javascript, Turbolinks, Stimulus.js, Vue.js, and more. Icons by Icons8

    © 2020 GoRails, LLC. All rights reserved.