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?

有帮助吗?

解决方案

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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top