Preseve line breaks from textarea in a Rails controller sent with submit_to_remote

I can’t believe that there is no standard way to do this, but I am sending content from a text field to a Rails controller and does not seem to save line breaks (of any shape).

Here is my code:

f.text_area :keywords, :cols => 50, :rows => 10

submit_to_remote 'button',  "#{t "add_keywords"}", 
     :html => {:id => 'add_keywords_button'},
     :url => { :controller=> :keywords, :action => :add_to_site },
     :escape => true,
     :loading=>"Form.Element.disable('add_keyword_button')",
     :complete=>"Form.Element.enable('add_keyword_button');",
     :update => { :success => "keywords_table_decorator", :failure => "message"

After sending this question, there is a controller, which simply should be able to analyze each keyword, line by line. I tried all the options on the following topic:

@keywords = params[:site_keywords][:keywords]
puts @keywords.gsub(/\n|\r|\r\n/,'*')

to see if I can get something that I can do with further splitting.

I would appreciate advice on working with this.

+3
source share
1 answer

. reset.css :

white-space: normal; 

- .

+2

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


All Articles