Domanda

Should I render a Partial with the information of the current data I have, or send a JSON and let javascript create the elements, with the information found in the JSON?

What's safer and more efficient?

È stato utile?

Soluzione

This is really a matter of personal preference. There's no simple single answer as to whether you should use a javascript framework (or even roll your own) on the front end, or to use various rails templates to send the data.

I think if you're buiding the entire front end in a javascript framework then stay consistent with that. If you're building most of the site with erb or haml templates then stick with that. I'd avoid mixing the two too much, personally.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top