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 ...
The asset pipeline which was introduced in Rails 3.1, has ...
#/status/256699237230845952
With the commit c82cf81f00f Action and Page caching has been extracted ...
#/status/253420357841723393
With the commit 3324e28804 ActiveRecord::SessionStore is extracted out of Rails into ...
The asset pipeline which was introduced in Rails 3.1, has ...
#/status/256699237230845952
With the commit c82cf81f00f Action and Page caching has been extracted ...
#/status/253420357841723393
With the commit 3324e28804 ActiveRecord::SessionStore is extracted out of Rails into ...
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..