The easy way is to change the field to text.

t.text :comment

When you are doing research on db data types and rails you need to know that
rails does a translation from the type you specify in the migration and the
type that they create in the database.

For Postgres, doing a t.string gets translated into a VARCHAR(255), NOT a
postgres string field.  t.text gets translated into a postgres text field.
Etc.  So you might need to have some  basic familiarity with the underlying
db types and which ones rails uses under the covers.

Mike

On Wed, Feb 9, 2011 at 1:59 PM, Jason Preston <[email protected]> wrote:

> I've been developing locally in Rails 3 using a SQLite database. I
> created a comments table in my DB using this migration:
>
> http://pastie.org/1546705
>
> Locally, I can type a 500-word essay into the comment box, hit post,
> and it saves no problem. On Heroku, I got the following response from
> the server logs when comments failed to post:
>
> http://pastie.org/1546711
>
> (the important bit being: PGError: ERROR:  value too long for type
> character varying(255) )
>
> This was weird since I thought I was using SQLite. A little digging
> told me that Heroku automatically uses Postgress and manages the
> translation automagically somehow. Cool -- except, looking up
> postgress (I think), I'm STILL supposed to define the field a "string"
> in my migration to get an unlimited, variable character field in the
> DB:
>
> http://www.postgresql.org/docs/8.4/static/datatype-character.html
>
> Anyone have any ideas about why my production DB is rejecting the
> longer strings, and maybe how I can fix it? I probably need to run an
> additional migration, but I'm not sure what to define other than
> "text"...
>
> Any help much appreciated,
>
> Cheers,
>  - J
>
> --
> You received this message because you are subscribed to the Google Groups
> "Heroku" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/heroku?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Heroku" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/heroku?hl=en.

Reply via email to