This project is archived and is in readonly mode.
Replacing ActiveRecord::Validations with Validatable
-
Jeremy Kemper
- Milestone cleared.
- 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
- Tag set to activemodel, activerecord, enhancement
I'm working on a branch which rewrites ActiveModel::Validations in a similar style to Validatable.
-
humbertop
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
- Milestone set to 2.x
-
Daniel Schierbeck
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. -
rjspotter
My ActiveModel implimentation can be found (https://github.com/rjspotter/rai..., "on github"). It works well enough for my purposes so far. I'm looking for others to give it a go and tell me if I'm smoking crack.
-
Emilio Tagua
Hey guys,
My ActiveModel implementation is here: http://github.com/miloops/rails/...
I took out the tests of ActiveRecord, including i18n tests, of each validation and all tests are passing right now in ActiveModel.
At the moment 9 of 10 validations are working, all except uniqueness since is the most AR dependent by implementation.
Of course this is still experimental but in AR there are 102 tests, 109 assertions in validations and 126 tests, 732 assertions in i18n validations. My ActiveModel implementation is running and passing 117 tests with 602 assertions of those tests.
If anyone interested in what i'm doing please let me know.
-
Jeremy Kemper
Wow, three implementations! Sounds like miloops' is the most compatible and complete so far. Perhaps you guys could collaborate on this?
-
August Lilleaas
Here's my take on an ActiveModel implementation: http://github.com/leethal/active...
It is very lightweight. The validations part is pretty much done. It will break ActiveRecord miserably, of course. I think ActiveRecord itself should handle all the naughty backwards compability, so that ActiveModel itself can stay lean and clean.
I'll be working on making the AR tests pass with my code in the coming weeks.
-
Pratik
- Assigned user set to Pratik
- State changed from open to new
- Milestone cleared.
We can/should push this once 2.3 is out. Meanwhile, maybe you guys could have your branches upto date and collaborate too :)
-
Pratik
- Assigned user changed from Pratik to josh
- State changed from new to incomplete
-
josh
- Assigned user cleared.