RailsCasts Pro episodes are now free!
Learn more or hide this
GitHub User: rcook
I think the proper way to prepare the fields HTML is as follows:
link_to(name, '#', class: "add_fields", data: {id: id, fields: escape_html_attribute(fields)})
and then define escape_html_attribute as follows:
escape_html_attribute
def escape_html_attribute(str) Rack::Utils.escape_html(str).gsub("\n", '
').html_safe end
This prevents the & in 
 from being escaped.
&


I think the proper way to prepare the fields HTML is as follows:
and then define
escape_html_attribute
as follows:This prevents the
&
in

from being escaped.