String with single quote

15 views
Skip to first unread message

Gm

unread,
Apr 26, 2015, 3:22:01 PM4/26/15
to rubyonra...@googlegroups.com
Hi,

I'm rendering a text inside a modal (bootstrap). But this text has this character: '
Example: Affonso Romano de Sant'Anna

When the text above is rendered, nothing occurs.
I think is some problem with that character.

Tips on how to solve this problem ?
Thanks.

Daniel Evans

unread,
Apr 26, 2015, 4:28:38 PM4/26/15
to rubyonra...@googlegroups.com
How are you rendering that text?

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-ta...@googlegroups.com.
To post to this group, send email to rubyonra...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/6e33193e-44b3-441b-8da7-b2c0d0278c8e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Daniel Evans

Gm

unread,
Apr 26, 2015, 5:57:30 PM4/26/15
to rubyonra...@googlegroups.com
Hi Daniel,

modal.find('.modal-body').html('<%= raw @text.content %>');

Walter Lee Davis

unread,
Apr 26, 2015, 6:23:43 PM4/26/15
to rubyonra...@googlegroups.com
I think if you step back, you will see what's going on here. Your single-quote in the Ruby-drawn content is prematurely ending the single quote surrounding the JavaScript rendered string.

Try escaping your content with gsub("'", "\'").

Walter
> To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/bf1a644d-a908-44f7-abc5-1581ae4a8fc2%40googlegroups.com.

Gm

unread,
Apr 26, 2015, 7:22:41 PM4/26/15
to rubyonra...@googlegroups.com
You were right.
Thanks.
Reply all
Reply to author
Forward
0 new messages