Question

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?

Était-ce utile?

La solution

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.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top