Search code examples
ruby-on-rails-3rails-migrations

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?


Solution

  • 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"