Thanks for your response and thanks for insoshi.

On Jun 17, 2:55 pm, "Michael Hartl" <[EMAIL PROTECTED]> wrote:
> OK, I think I found the problem.  MySQL (and possibly other databases
> as well) won't let you set a default value for a text field (as you
> can with a string).  This means that a new Person object will have a
> *nil* description by default, instead of a blank one:
>
> $ script/console>> Person.new.description
>
> => nil
>
> What does this have to do with length validations?  Well, under the
> hood Rails looks at description.length in order to perform the
> validation---but nil.length raises an exception! Unfortunately, Rails
> misinterprets this, thinking that the field is too long instead of
> simply being nil.
>
> The fix is to add an Active Record callback before the validation to
> set the description to the empty string if it's nil:
>
>   before_validation :prepare_email, :handle_nil_description
>
> with
>
>     def handle_nil_description
>       self.description = "" if description.nil?
>     end
>
> As a side note, for some reason there wasn't a validation on the
> description length on the master branch, so I added one.
>
> Michael
>
>
>
> On Mon, Jun 16, 2008 at 4:40 PM, Fountain <[EMAIL PROTECTED]> wrote:
>
> > Thanks Michael,
>
> > Here's a little more information:
>
> > The problem did not occur until I tried to deploy the application on
> > hostingrails.com
> > I first encountered the problem when trying run the install. The rake
> > failed at the 'create_admin' migration step.
> > I got around this by adding some short description text for the admin
> > account and the migration went through fine.
>
> > I'm assuming the problem has something to do with creating a new
> > 'person' with a blank text field.
> > My production database has 'null' as the default for the description
> > column.
>
> > On Jun 16, 3:32 pm, "Michael Hartl" <[EMAIL PROTECTED]> wrote:
> >> That's weird.  I'll try to take a look at this tomorrow and see if I
> >> can reproduce the problem.
>
> >> Michael
>
> >> On Sat, Jun 14, 2008 at 11:15 AM, Fountain <[EMAIL PROTECTED]> wrote:
>
> >> > I tried adding a line to my code that validates the size of the person
> >> > description column, but when I do this, every time I try to create a
> >> > new user, I get an error saying 'Description can not exceed the 2000
> >> > character maximum'.
>
> >> > My current signup form does not actually ask for the description so my
> >> > guess is this might be some sort of database misunderstanding. I
> >> > assume the problem is somehow connected to the fact that 'description'
> >> > is the only column that is a 'text' box. The others are all strings
> >> > and integers.
>
> >> > Any ideas? Is this a known problem. I should mention I am pretty new
> >> > to rails and programming so this might be a simple thing that I am
> >> > just not aware of.
>
> >> > Additionally I don't think I ran into this problem until I deployed my
> >> > production version.
>
> >> > Thanks.
>
> >> --
> >> Michael Hartl
> >> Insoshi social softwarehttp://insoshi.com/
>
> --
> Michael Hartl
> Insoshi social softwarehttp://insoshi.com/
--~--~---------~--~----~------------~-------~--~----~
Insoshi developer site: http://dogfood.insoshi.com/
Insoshi documentation: http://docs.insoshi.com/

You received this message because you are subscribed to the Google
Groups "Insoshi" 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/insoshi?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to