Set UTF-8 as default for Ruby 1.9.3

前端 未结 4 1136
孤独总比滥情好
孤独总比滥情好 2020-12-05 20:01

I\'m on Rails 4 and Ruby 1.9.3

I use \"strange\" characters very often, so I have to declare UTF-8 encoding at the top of all .rb files.

Is there any way to

4条回答
  •  萌比男神i
    2020-12-05 20:25

    in Ruby 1.9 the default is ASCII

    in Ruby 2.0 the default is UTF-8.


    change Ruby version

    or

    config.encoding = "utf-8" # application.rb
    

    and in your database.yml

    development:
         adapter:  your_db
         host:     localhost
         encoding: utf8
    

提交回复
热议问题