views:

27

answers:

3

Suppose we have a textarea in which we put example string. Textbox contain :

Earth is revolving around the Sun.

But at the time of saving, I just pressed a enter key after "the sun". Now the statements in texbox ::

Earth is revolving around
 the Sun.

Now I am trying to fetch the data but unable just because of that enter key pressed by me in between the string. So please suggest me how to escape this enter key ??

Thanks in Advance !!!

A: 

You just need delete all enter key in before_save method

class user
  before_save :no_enter

  def no_enter
    self.content = self.content.gsub('\n', '')
  end
end
shingara
No.. This statement gsub replace each and every space by \n. some alternate option we have to search ??
Rahul Patil
A: 

Enter key is pressed within the text area then \r\n entered in db. So by replacing this value we can escape it by an other alphabet or symbol.

Rahul Patil
A: 

You should totally drop that and try jQuery.

Tom Anderson