I want to post some data as an html attribute. Suppose there is a rails variable
@fields = [{:name => "id", :type => :integer}]
I want to post in the page for use with jquery's .data(). So in the .html.erb I have
<%= form_tag( {:action => 'whatever'}, {... , :"data-fields" => h(@fields.to_json)}) %>
But while rendering, the quotations in string [{"name":"id","type":"integer"}]
mess up the other attributes because Rails form_tag uses double quotes to enclose the whole json string in double quotes. How do I post json with strings as an attribute from Rails?
Have you tried the following?