I would like to pass params hash into jQuery. The thing is, I want to pass an array of strings.
For now I am using: In HAML:
.hidden{id: 'correct_solutions_params', data: {correct_solutions: params[:task][:correct_solutions]}}
which gives following HTML:
<div class="hidden" data-correct-solutions="["a", "c", "d"]" id="correct_solutions_params"></div>
Obviously
params[:task][:correct_solutions] = ['a', 'c', 'd']
And now I should access data in jQuery (did not try yet, but should work):
var datadump = ($('#correct_solutions_params').data('correct-solutions'));
The thing is, that this trick is really old. I am using Rails 5. Is there a better, newer solution then this? Is that considered secure?