In my Rails program I have a script that gets a string from my database and passes it with erb to a function in javascript. However, when the string gathered from the database has a line break in it (like a newline character from pressing 'enter') I end up in the following situation:
<%= puts @comment[:reference] %>
prints the string correctly in the console, with the blank lines included.
But,
alert('<%= @comment[:reference] %>')
does nothing!
I have no issues when the string is contained in one line.
Why is my string being interpreted correctly within the erb tag, but failing to pass correctly to the javascript?