ActiveRecord :: StatementInvalid(PG ::错误:错误:类型字符变化的值太长(255)

时间:2013-12-28 16:08:30

标签: ruby-on-rails ruby-on-rails-3 activerecord heroku

帮助!在我的系统中,用户搜索书籍并选择一本书并为书籍创建一个组。但是有些用户无意中为一本书创建了三个组。然后我删除了其他人。在那之后,我突然得到了下面的错误。

现在,用户无法发布任何文章。

☆heroku日志

2013-12-28T15:58:35.611503+00:00 app[web.1]: Started POST "/group_messages/7/group_message_comments" for 119.72.194.92 at 2013-12-29 00:58:35 +0900
2013-12-28T15:58:35.614373+00:00 app[web.1]: Processing by GroupMessageCommentsController#create as HTML
2013-12-28T15:58:35.614373+00:00 app[web.1]:   Parameters: {"utf8"=>"✓", "authenticity_token"=>"SMyCZ8R97XIEMWQTzdYFMwcBRjtuoOgp7EDtpebyJRU=", "group_message_comment"=>{"member_id"=>"2", "group_message_id"=>"7", "group_id"=>"5", "content"=>"他人の地位を買収する、というより、その話題の彼が主宰するメンバーシップの中にお金を払って入ることができないという意味ですね。こちらはご参考です。http://idioms.thefreedictionary.com/buy+way+in\\r\\nSun Valley was always very reassuring, because unlike most elephant bumps, one could not buy one’s way\\r\\nin.ほかのこういうビッグネームの集まる類いのイベント(elepaht bump)の中には、お金さえ払えば参加できるものが主流なんでしょうね"}, "commit"=>"Comment", "group_message_id"=>"7"}
2013-12-28T15:58:35.624060+00:00 app[web.1]: 
2013-12-28T15:58:35.624060+00:00 app[web.1]: 
2013-12-28T15:58:35.624060+00:00 app[web.1]: 
2013-12-28T15:58:35.624060+00:00 app[web.1]:   app/controllers/group_message_comments_controller.rb:47:in `create'
2013-12-28T15:58:35.624060+00:00 app[web.1]: ActiveRecord::StatementInvalid (PG::Error: ERROR:  value too long for type character varying(255)
2013-12-28T15:58:35.624060+00:00 app[web.1]: : INSERT INTO "group_message_comments" ("content", "created_at", "group_id", "group_message_id", "member_id", "read", "updated_at") VALUES ($1, $2, $3, $4, $5, $6, $7) RETURNING "id"):
2013-12-28T15:58:35.621719+00:00 app[web.1]: Completed 500 Internal Server Error in 7ms

☆group.rb

class Group < ActiveRecord::Base
  attr_accessible :admin, :memo, :name

  has_many :group_in_members, :dependent => :destroy
  has_many :members, :through => :group_in_members
  has_many :group_messages, :dependent => :destroy


end

☆schema.rb

ActiveRecord::Schema.define(:version => 20131219064155) do

  create_table "comments", :force => true do |t|
    t.integer  "member_id"
    t.integer  "message_id"
    t.string   "content"
    t.datetime "created_at", :null => false
    t.datetime "updated_at", :null => false
  end

  create_table "contacts", :force => true do |t|
    t.string   "name",       :null => false
    t.string   "email",      :null => false
    t.text     "content",    :null => false
    t.datetime "created_at", :null => false
    t.datetime "updated_at", :null => false
  end

  create_table "friends", :force => true do |t|
    t.integer  "member_id",  :null => false
    t.integer  "friend_id",  :null => false
    t.datetime "created_at", :null => false
    t.datetime "updated_at", :null => false
  end

  create_table "group_in_members", :force => true do |t|
    t.integer  "group_id",   :null => false
    t.integer  "member_id",  :null => false
    t.datetime "created_at", :null => false
    t.datetime "updated_at", :null => false
  end

  create_table "group_message_comments", :force => true do |t|
    t.integer  "member_id",                           :null => false
    t.integer  "group_id",                            :null => false
    t.string   "content"
    t.datetime "created_at",                          :null => false
    t.datetime "updated_at",                          :null => false
    t.integer  "group_message_id",                    :null => false
    t.boolean  "read",             :default => false
  end

  create_table "group_messages", :force => true do |t|
    t.integer  "member_id",                     :null => false
    t.text     "content"
    t.datetime "created_at",                    :null => false
    t.datetime "updated_at",                    :null => false
    t.integer  "group_id",                      :null => false
    t.integer  "page"
    t.integer  "line"
    t.string   "name"
    t.string   "username"
    t.boolean  "kaiketsu",   :default => false
  end

  create_table "groups", :force => true do |t|
    t.datetime "created_at",                :null => false
    t.datetime "updated_at",                :null => false
    t.string   "imageurl"
    t.string   "author"
    t.string   "publish"
    t.date     "published"
    t.integer  "page"
    t.string   "isbn"
    t.string   "asin"
    t.string   "name"
    t.text     "detailurl",  :limit => 255
  end

  create_table "members", :force => true do |t|
    t.string   "user"
    t.string   "pass"
    t.string   "name"
    t.string   "mail"
    t.text     "memo"
    t.boolean  "admin"
    t.datetime "created_at",          :null => false
    t.datetime "updated_at",          :null => false
    t.string   "password_digest"
    t.string   "pass_confirmation"
    t.string   "field"
    t.string   "place"
    t.string   "experience"
    t.string   "url"
    t.string   "provider"
    t.string   "uid"
    t.string   "image"
    t.string   "avatar_file_name"
    t.string   "avatar_content_type"
    t.integer  "avatar_file_size"
    t.datetime "avatar_updated_at"
  end

  create_table "messages", :force => true do |t|
    t.integer  "member_id"
    t.text     "content"
    t.datetime "created_at", :null => false
    t.datetime "updated_at", :null => false
  end

  create_table "sessions", :force => true do |t|
    t.string   "session_id", :null => false
    t.text     "data"
    t.datetime "created_at", :null => false
    t.datetime "updated_at", :null => false
  end

  add_index "sessions", ["session_id"], :name => "index_sessions_on_session_id"
  add_index "sessions", ["updated_at"], :name => "index_sessions_on_updated_at"

end

1 个答案:

答案 0 :(得分:0)

我不确定“DB的组”是什么意思,但这似乎是一个简单的尝试插入一个对varchar(255)的列定义来说太大的值的情况。如果您需要更多帮助,我认为您需要发布更多信息(例如您删除的内容以及您认为与此错误相关的原因)。