Right now I'm calling content_ in my code ...
I think the best approach would be to define a helper: Then just use your & lt ; % Content_for: JavaScript -%> & Lt;% = "var boxplot_data =# {@survey.boxplot_answers.to_json};" & Gt%; & Lt;% end -% & gt; Instead, once I would like to convert an array one time, but I would add Array to the boxple_data and then have it displayed as a var. This way I can make it easier to read my code because I do not see it near to my partial data usage where I prepare it to add to the scene.
def add_to_boxplot (val) @boxplot || = [] @boxplot & lt; & Lt; Val & Def json_boxplot "var boxplot_data = # {@@spaceplot.to_json}" end
add_to_boxplot
and instead of Yield (javascript)
usage json_boxplot
.
Comments
Post a Comment