Re: ActiveRecord bottom half

Bill Walton
2007-07-07T17:36:41Z

Hi Perry,

Perry Smith wrote:

> The big thing that is frustrating me with the existing
> methods is how to do validation.  As I said, I can not
> get validates_presence_of to work for me in a
> polymorphic belongs_to.

It would be easier to help if you posted the SQL script or migration that
you''re using to create the tables and the related models.

> I''m torn between trying to do validation up in Rails
> or down in the DB.

We do validations in our models.  Rails treats the DB as a simple container.
My experience is that that''s the only viable option if you want the
freedom
to change databases.

<snip awaiting more information>

> The only thing that PostgreSQL gives me is rules and stored
> procedures to do the validation in the DB.  I''m not sure but I
> think those are not in other DB''s.

They''re not in some, and they''re handled differently in
others.  It''s one of
the fundamental ways that database vendors achieve lockin.  Being locked in
to an open source DB is still being locked in.  Not good, IMHO.

> To recap, I''m not wanting to go down this path.  I just
> want to validate the database and keep it valid at all times.

That''s not going to be a problem, assuming you''re willing to
let Rails and
AR do their thing, rather than impose a preconceived solution on them.

Post some code.

Best regards,
Bill