Cedric Tineo
2011-Jun-26 20:18 UTC
ActionView::Template::Error (Cannot modify SafeBuffer in place):
Hello, Trying to upgrade an app that was running fine in 3.0.3 to 3.0.9 and while everything works well, I get this error: ActionView::Template::Error (Cannot modify SafeBuffer in place): When passing a string to this function (in application_helper.rb) through a simple: <%= format_me(article[shortdesc])%> def format_me(text, html_options={}, options={}) text = ''''.html_safe if text.nil? start_tag = tag(''p class=grey'', html_options, true) text = sanitize(text) unless options[:sanitize] == false text.gsub!(/\r\n?/, "\n") # \r\n and \r -> \n text.gsub!(/\n\n+/, "</p><br />\n\n#{start_tag}") # 2+ newline -> paragraphtext.gsub!(/\r\r+/, "</p><br />\n\n#{start_tag}") # 2+ newline -> paragraphtext.gsub!(/([^\n]\n)(?=[^\n])/, ''\1<br />'') # 1 newline -> br text.gsub!("*b*", ''<b>'') text.gsub!("*bb*", ''</b>'') text.gsub!("*r*", ''<span class=red>'') text.gsub!("*rr*", ''</span>'') text.gsub!("*sp*", '' '') text.insert 0, start_tag text.html_safe.safe_concat("</p>") end I don''t understand well enough what changed between 3.0.3 and 3.0.9 to understand what I should change in this function and what part is now wrong. Can anyone help? Thanks! Cedric Tineo -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Frederick Cheung
2011-Jun-28 22:07 UTC
Re: ActionView::Template::Error (Cannot modify SafeBuffer in place):
On Jun 26, 9:18 pm, Cedric Tineo <tineo.ced...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > I don''t understand well enough what changed between 3.0.3 and 3.0.9 to > understand what I should change in this function and what part is now > wrong. >In a nutshell, don''t call gsub! on strings that have been marked as safe Fred> Can anyone help? Thanks! > > Cedric Tineo-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.