I have the following code in my view, I don't understand why the gsub doesn't work.
<div class="section" id="<%= section.title.gsub(/_/, ' ') %>">
When .title = "Test Title"
it just returns "Test Title"
rather than "Test_Title"
What's going wrong here?
它应该是相反的方式:
"Test Title".gsub(/ /, '_') #=> "Test_Title"
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.