#401 open
Jon Wood

Replacing ActiveRecord::Validations with Validatable

Reported by Jon Wood | June 12th, 2008 @ 12:07 PM | in 2.x

I would like to replace ActiveRecord::Validations with the Validatable gem, since this would allow more flexibility in design of models - sepcifically that models which do not extend ActiveRecord will be as simple to add validations to as database backed models.

Before I start on this, is there any interest in doing so?

Comments and changes to this ticket

  • Jeremy Kemper

    Jeremy Kemper June 12th, 2008 @ 05:16 PM

    • → Milestone changed from “” to “2.2”
    • → State changed from “new” to “open”

    I like Validatable's OO design. Have you seen the validations extracted into Active Model? We could merge Validatable into it, retaining compatibility, then replace Active Record's implementation with an Active Model dependency.

  • Ruy Asan

    Ruy Asan July 10th, 2008 @ 01:54 AM

    • → Tag changed from “” to “activemodel activerecord enhancement”

    I'm working on a branch which rewrites ActiveModel::Validations in a similar style to Validatable.

    Github here, long-winded write up here

  • humbertop

    humbertop September 2nd, 2008 @ 01:15 PM

    Hello, I'm getting familiar with Validatable. I want to change all the ActiveRecord Validations in my applications to Valdatable. But I have a question, since ActiveRecord also handles associations how can use Validatable and keep working the models relationships.

  • DHH

    DHH September 12th, 2008 @ 08:32 PM

    • → Milestone changed from “2.2” to “2.x”
  • Daniel Schierbeck

    Daniel Schierbeck November 8th, 2008 @ 09:54 PM

    Having an easy way to validate non-ActiveRecord objects would be awesome. The current hack I'm using is ugly as hell.

    Using a third party library seems to make sense, as this is a common problem in a lot of Ruby code, and having a single place to put stuff is preferable -- ActiveRecord and ActiveModel could just extend the library with e.g. validates_association.

Please Login or create a free account to add a new comment.

You can update this ticket by sending an email to from your email client. (help)

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

Source available from github

The Git repository resides at http://github.com/rails

Check out the current development trunk (Edge Rails) with:

git clone git://github.com/rails/rails.git

Creating or reviewing a patch

See the contributor guide.

Creating a feature request

Please don't. If you want a new feature in Rails, you'll have to pull up your sleeves and get busy yourself. Or convince someone else to do it. See the contributor guide on how to get going. But posting them here is just going to lead to ticket root.

Creating a bug report

When creating a bug report, be sure to include as much relevant information as possible. Post the code sample that causes the problem. Preferably, alter the unit tests and show through either changed or added tests how the expected behavior is not occuring.

Security vulnerabilities should be reported via an email to security@rubyonrails.org, do not use trac for reporting security vulnerabilities. All content in trac is publicly available as soon as it is posted.

Then don't get your hopes up. Unless you have a "Code Red, Mission Critical, The World is Coming to an End" kinda bug, you're creating this ticket in the hope that others with the same problem will be able to collaborate with you on solving it. Do not expect that the ticket automatically will see any activity or that others will jump to fix it. Creating a ticket like this is mostly to help yourself start on the path of fixing the problem and for others to sign on to with a "I'm having this problem too".

Shared Ticket Bins