Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added possibility to set validation regexp pattern in model instead of g... #191

Closed
wants to merge 1 commit into from

Conversation

aderyabin
Copy link

We use ancestry in our project for several models. One model uses UUID format as primary key (other uses integer by default). In this case we need to have separate ANCESTRY_PATTERN for this model. I suggest to define this constant in model instead of globally declaration.

Let's describe in example:

class Category < ActiveRecord::Base
  has_ancestry
end

class GlobalCategory < ActiveRecord::Base
  # lets set pattern for UUID type 
  ANCESTRY_PATTERN = /\A[\w\-]+(\/[\w\-]+)*\z/
  has_ancestry
end

@razum2um
Copy link

👍

@mmzoo
Copy link

mmzoo commented Dec 1, 2014

I think I'd prefer this approach: boardiq@80124cc What do you think? That would also be consistent with the documentation #174 (comment) :)

@kbrock
Copy link
Collaborator

kbrock commented Feb 6, 2016

Thank you for the PR @aderyabin

I'm closing this in favor of allowing people to declare their id pattern as a parameter. Hope to merge #262 and get this feature in soon

@kbrock kbrock closed this Feb 6, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants