So I have a comments table that is structured like this:

# == Schema Information
#
# Table name: comments
#
#  id         :integer         not null, primary key
#  body       :string(255)
#  notified   :boolean
#  user_id    :integer
#  stage_id   :integer
#  created_at :datetime
#  updated_at :datetime
#  client_id  :integer
#  author     :string(255)

This is the error message I am getting:

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

How do I store long text in a PG column using Rails 3.x and Heroku?

What would the migration look like to fix this issue?

Thanks.

share|improve this question

1  
Are you looking for anything more than: stackoverflow.com/questions/4103141/… ? – John Plummer Mar 20 at 10:20
No...that's exactly what I was looking for. Thanks! – marcamillion Mar 20 at 11:17
feedback

1 Answer

up vote 7 down vote accepted

You would need to use text instead of string.

Migration would be something along the lines of:

change_column :comments, :body, :text, :limit => nil
share|improve this answer
One change to that I would make is, make sure to specify :limit => nil, otherwise a limit of 255 will be added to the schema in Rails 3.x. – marcamillion Mar 20 at 11:19
feedback

Your Answer

 
or
required, but never shown
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.