Frage

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?

War es hilfreich?

Lösung

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.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top