[英]Rails gsub not working in view
I have the following code in my view, I don't understand why the gsub doesn't work. 我在视图中有以下代码,我不明白为什么gsub不起作用。
<div class="section" id="<%= section.title.gsub(/_/, ' ') %>">
When .title = "Test Title"
it just returns "Test Title"
rather than "Test_Title"
当
.title = "Test Title"
它只返回"Test Title"
而不是"Test_Title"
What's going wrong here? 这里出了什么问题?
它应该是相反的方式:
"Test Title".gsub(/ /, '_') #=> "Test_Title"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.