Dan Herman
Dan Herman

Reputation: 1505

rails migration change default value of column with new line character

def change
    change_column :customer, :email_text, :string, :default => 'First Line \n Second Line \n Third Line'
end

I'm trying to get this migration such that my default value for this column will work with new lines. When I use this field with simple_form as so:

<%= f.input :email_text, :as => :text, :label => 'E-Mail Text', %>

The newline characters are showing up as \n's instead of new lines. Anyone have any idea how I can get this to work?

Upvotes: 1

Views: 1270

Answers (1)

Dave S.
Dave S.

Reputation: 6419

Another fine example of this ruby "gem":

1.9.3p327 :001 > '\n' == "\n"
 => false

Try it as:

:default => "First Line \n Second Line \n Third Line"

Upvotes: 2

Related Questions