无法在rails控制台中创建包含中文字符的条目

时间:2013-08-28 16:16:46

标签: ruby-on-rails

我正在为铁路上的红宝石中国学生创建一个平台。这是我的架构

ActiveRecord::Schema.define(version: 20130827203308) do

  # These are extensions that must be enabled in order to support this database
  enable_extension "plpgsql"

  create_table "posts", force: true do |t|
    t.text    "message"
    t.integer "student_id"
  end

  add_index "posts", ["student_id"], name: "index_posts_on_student_id", using: :btree

  create_table "students", force: true do |t|
    t.string   "first_name"
    t.string   "last_name"
    t.string   "email"
    t.string   "number"
    t.string   "college"
    t.string   "password"
    t.float    "budget"
    t.string   "picture"
    t.datetime "created_at"
    t.datetime "updated_at"
  end

当我前往rails控制台并执行此操作时

Post.create(:message => "I am looking at a 3 bedroom apartment") 

我可以开始并将其提交到我的数据库中。

但是当我做的时候

Post.create(:message => "我在Suffolk University附近想租一个3房一厅的apt有没有同学有兴趣“)

我的rails控制台冻结。

我在posts表中使用了“text”类型的消息。我应该使用“字符串”吗?或者我应该使用某种语言宝石来做到这一点?

1 个答案:

答案 0 :(得分:0)

尝试使用readline安装rvm包并重新编译您的ruby:

$ rvm pkg install readline
$ rvm install <your_ruby_version>