I tried to upgrade my Rails 2.3.11 application to Rails 3.2.3, but this function in ApplicationHelper does not work properly anymore in the browser (in Rails console everything is fine):
def basic_markup(text)
if text
text.gsub!(/(\A|\s|\[|\()_(.+?)_/iu, '\1<em>\2</em>')
text.gsub!(/(\A|\s|\[|\()#(.+?)([^&])#/iu, '\1<del>\2\3</del>')
text.gsub!('->', '→')
text.gsub!('<-', '←')
end
text
end
text = '#strikeout# normal _italic_'
puts basic_markup(text)
# Rails 2.3.11
# => "<del>strikeout</del> normal <em>italic</em>"
# Rails 3.2.3
# => "#strikeout# normal <em>italic</em>"
Sample on Rails 2.3.11: http://moly.hu/karcok/150362
The same on Rails 3.2.3: http://moly.hu:3000/karcok/150362
What's wrong?
Copying the answer from the comments in order to remove this question from the "Unanswered" filter:
Frost suggested an upgrade:
Update to my comment above: I just tried creating a new rails 3.2.3 project, put that method in the
application_helper
and calling it from a view with the same text, and works just fine. I think you're missing something somewhere else.
Nagy Bence confirmed:
Problem solved, maybe Rails' simple_format has changed between 2.3.11 and 3.2.3, but now it runs correctly. Thanks for the comments!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.