Skip to main content
Ask A Question
You’re not receiving notifications from this thread.

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

General • Asked by Chris Oliver

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.

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.

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

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 ...

Login or Create An Account to join the conversation.

Subscribe to the newsletter

Join 30,005+ developers who get early access to new screencasts, articles, guides, updates, and more.

    By clicking this button, you agree to the GoRails Terms of Service and Privacy Policy.

    More of a social being? We're also on Twitter and YouTube.