ruby-on-rails - PG::StringDataRightTruncation:错误:PostgreSQL字符串(255)限制| Heroku

标签 ruby-on-rails heroku ruby-on-rails-4

我有一个Listings controller,用户可以添加描述。如果描述很长,应该是正确的,我在Heroku中收到此错误:

ActiveRecord::StatementInvalid (PG::StringDataRightTruncation: ERROR:  
value too long for type character varying(255)


我怎样才能解决这个问题?

编辑

我发现(约翰也说过)我必须将表字符串(有限制)更改为:text,这是无限的。但是,仅更改迁移中的表似乎不起作用。

我的编辑列表迁移

class CreateListings < ActiveRecord::Migration
def change
create_table :listings do |t|
  t.string :title
  t.text :description, :limit => nil

  t.timestamps
end
end
end


但是我仍然遇到Heroku的麻烦->

    2013-07-29T09:39:05.069692+00:00 app[web.1]: ActiveRecord::StatementInvalid (PG::StringDataRightTruncation: ERROR:  value too long for type character v rying(255)
2013-07-29T09:39:05.069870+00:00 app[web.1]:
2013-07-29T09:39:05.069692+00:00 app[web.1]: : INSERT INTO "listings" ("created_at", "description", "image_content_type", "image_file_name", "image_fil _size", "image_updated_at", "price", "title", "updated_at", "user_id") VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10) RETURNING "id"):
2013-07-29T09:39:05.069870+00:00 app[web.1]:   app/controllers/listings_controller.rb:35:in `block in create'
2013-07-29T09:39:05.069870+00:00 app[web.1]:   app/controllers/listings_controller.rb:34:in `create'
2013-07-29T09:39:05.069870+00:00 app[web.1]:
2013-07-29T09:39:05.069860+00:00 heroku[router]: at=info method=POST path=/listings host=vaultx.herokuapp.com fwd="178.59.173.169" dyno=web.1 connect=3 s service=1882ms status=500 bytes=1266

最佳答案

似乎将列指定为:text类型而不是:string可以解决此问题。

关于ruby-on-rails - PG::StringDataRightTruncation:错误:PostgreSQL字符串(255)限制| Heroku,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17920028/

相关文章:

heroku:在发布阶段刷新redis

ruby-on-rails - 如何从其他类( Controller 外部)调用 send_data 和 send_file

ruby-on-rails - rails 3.2.13 : Routing Error (No route matches [GET] "/stylesheets/application.css")

ruby-on-rails - 我在这里寻找什么 rails 关系?

ruby-on-rails - ruby on Rails 应用程序重新启动时执行脚本

postgresql - 使一个值首先出现在下拉其他值之后

ruby-on-rails - 页面加载时未应用布局

ruby-on-rails - OpenStack API 的开源 Rails gem?

django - Heroku 上的 Django 入门问题

postgresql - Mac OS X 10.11 - 将 Postgres 添加到 $PATH 失败