I was surprised as there is no function in ruby to convert all newline characters to <br>.
Here is a php nl2br equivalent method to convert all newline characters (\n) to break tag (<br>) in a string.
def nl2br(s)
s.gsub(/\\n/, '<br>')
end
I was surprised as there is no function in ruby to convert all newline characters to <br>.
Here is a php nl2br equivalent method to convert all newline characters (\n) to break tag (<br>) in a string.
def nl2br(s)
s.gsub(/\\n/, '<br>')
end
I have wrote my first plugin(state_select). This plugin allows to ...
I was using acts_as_searchable for one of my project, which ...
If you guys want to change timezone of your ubuntu ...
My new Notebook Configuration: Intel Core Duo Processor 1.66 GHz, Intel ...
Hey guys, Yesterday I did an interesting server configuration. Actually ...
Cross Posted from http://vinsol.com/blog Who doesn't know GitHub now a days, ...
Returns Time.zone.now when config.time_zone is set, otherwise just returns Time.now
Array#rand is deprecated in favor of Array#random_element and will be ...
New edge rails deprecations: Time#last_year is deprecated in favor of Time#prev_year Time#last_month ...
Using ftp to download multiple files using 'mget' command is ...
Returns Time.zone.now when config.time_zone is set, otherwise just returns Time.now
Array#rand is deprecated in favor of Array#random_element and will be ...
New edge rails deprecations: Time#last_year is deprecated in favor of Time#prev_year Time#last_month ...
Just a quick note, If you are getting "uninitialized constant ...
Cross Posted from http://vinsol.com/blog At VinSol, we have been ...
def nl2br(s)
s.gsub(/\n/, ”)
end
This would be more appropriate
This will remove all new line characters not replace them by <br>
I believe he was reffering to the /\n/ part. Since /n/ will remove all n-characthers and replace them with
simple_format text helper do the trick
http://api.rubyonrails.org/classes/ActionView/Helpers/TextHelper.html#M000623
for development in rails, just use simple_format(str) function.
Its really simple..