Closed kostia closed 12 years ago
I would prefer not to include a uniqueness validator because the client can't guarantee uniqueness in the case of concurrent writes -- I look at it as a pleasant fiction. I'll turn on the wiki, though, thanks!
On Oct 19, 2012, at 12:31, Kostiantyn Kahanskyi notifications@github.com wrote:
Do we need a uniqueness validator? The simplest one would look like this:
class UniquenessValidator < ActiveModel::EachValidator def validate_each(record, attribute, value) if record.class.filter(term: {attribute => value}).any? record.errors.add attribute, :taken end end end
Otherwise it would be great to add have an appropriate entry in the wiki (currently disabled somehow).
— Reply to this email directly or view it on GitHubhttps://github.com/brewster/elastictastic/issues/18.
Do one need a uniqueness validator? The simplest one would look like this:
Otherwise it would be great to have an appropriate entry in the wiki (currently disabled somehow).