[typo] Ecto not working for me - can't post, need help

Chris Bailey chris at codeintensity.com
Fri Jan 13 15:49:52 EST 2006

Ok, I finally fixed this, and it *may* point out a bug, or what I'd
really say, a need for an additional safeguard.  The problem I'd had,
as seen below, is that my migrate hadn't gone well, and I was left
with various articles having null guid values.  Scott suggested
iterating them and re-saving as seen below.  But, that didn't work.
However, I only needed to slightly modify that.  Looking at the code
pointed out how to do this :)  So, I simply did this:

      Article.find(:all).each do |a|
         if a.guid.blank?
           a.guid = UUID.random_create.to_s

What I saw in the code was that the guid is generated only when the
entry is created (via :before_create).  So, it seems like it might be
useful to have a similar check as above, for saving/update, to ensure
the guid isn't empty.  Theoretically that shouldn't happen, but might
not be a bad safeguard.

On 12/31/05, Chris Bailey <chris at codeintensity.com> wrote:
> On 12/31/05, Scott Laird <scott at sigkill.org> wrote:
> >
> > On Dec 30, 2005, at 9:08 PM, Chris Bailey wrote:
> >
> > > My apologies for the premature send.  I now/also tried posting from
> > > the web admin interface of typo, and got an error:
> > >
> > >   1 error prohibited this article from being saved
> > >   There were problems with the following fields:
> > >   Guid has already been taken
> > >
> > > I have recently done some big upgrades/migrates (was on 47x now on
> > > 801), and had some trouble along the way.  I thought everything was
> > > fixed up, but obviously not.  I see that this has been brought up
> > > somewhat recently (Nov 30) on the list
> > > (http://www.mail-archive.com/typo-list@rubyforge.org/msg01069.html),
> > > but there was no reply.  Tom or anyone, was there a resolution?
> >
> > Try this from ./script/console:
> >
> >    Article.find(:all).each do |a|
> >      a.save if a.guid.blank?
> >    end
> >
> That didn't fix it (it did seem to echo each entry out to the console
> though).   I checked the DB and the guid column for for the content
> table has most entries still null.
> Also, I have a completely empty articles table, is that right?

Chris Bailey
chris.bailey at gmail.com

More information about the Typo-list mailing list