Removal and NBSP; in Rails

I am trying to delete all   in my model with the following method:

 def about_us_sans_spaces self.about_us = replace(self.about_us, " ", " ") end 

Besides! it turns out that "replacement" is not a method in rails. How to remove   ?

Remember, I already tried to sanitize, simple_format. My view is as follows:

 = truncate(sanitize(simple_format(organization.about_us_sans_spaces), :tags => ''), 125).titleize 
+4
source share
2 answers
 def about_us_sans_spaces self.about_us.gsub!(" ", "") end 

Edit: Note that gsub () also accepts a regular expression, so you can catch all instances regardless of their capitalization:

 about_us.gsub(/ /i,"") 
+18
source

Try using about_us.strip Hope this also helps you.

0
source

Source: https://habr.com/ru/post/1312243/


All Articles