<commit_before># validates_duplicity_of

ActiveRecord (>= 3) callback which handle the name duplication in your model with ease.
Ruby 2 only!

**Example :**

Untilted File > Untilted File (1) > Untilted File (2) …

## Installation

Add this line to your application's Gemfile:

    gem 'validates_duplicity_of'

And then execute:

    $ bundle

Or install it yourself as:

    $ gem install validates_duplicity_of

Or with security:

	$ wget https://gist.github.com/madwork/7026195/raw/6e06ae0754eecdf78cbb091e816597e860022dc1/gem-public_cert.pem -O madwork-public_cert.pem
	$ gem cert --add madwork-public_cert.pem
	$ gem install validates_duplicity_of --trust-policy=HighSecurity

## Usage

Use method `validates_duplicity_of` with attribute in your Rails model. Scope is optional. Default callback is `before_save`.

	class Post < ActiveRecord::Base
	  validates_duplicity_of :name, scope: :user_id
	end
	
	p = Post.create name: "Foo", user_id: 1
	p.name
	=> "Foo"
	
	p = Post.create name: "Foo", user_id: 1
	p.name
	=> "Foo (1)"
	
	class Note < ActiveRecord::Base
	  validates_uniqueness_of :name
	  validates_duplicity_of :name, callback: :before_validation
	end


## Contributing

1. Fork it
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create new Pull Request<commit_msg>Fix typo and shorten cert gist url<commit_after># validates_duplicity_of

ActiveRecord (>= 3) callback which handle the name duplication in your model with ease.
Ruby 2 only!

**Example :**

Untitled File > Untitled File (1) > Untitled File (2) …

## Installation

Add this line to your application's Gemfile:

    gem 'validates_duplicity_of'

And then execute:

    $ bundle

Or install it yourself as:

    $ gem install validates_duplicity_of

Or with security:

	$ wget http://git.io/hHL6zQ -O madwork-public_cert.pem
	$ gem cert --add madwork-public_cert.pem
	$ gem install validates_duplicity_of --trust-policy=HighSecurity

## Usage

Use method `validates_duplicity_of` with attribute in your Rails model. Scope is optional. Default callback is `before_save`.

	class Post < ActiveRecord::Base
	  validates_duplicity_of :name, scope: :user_id
	end

	p = Post.create name: "Foo", user_id: 1
	p.name
	=> "Foo"

	p = Post.create name: "Foo", user_id: 1
	p.name
	=> "Foo (1)"

	class Note < ActiveRecord::Base
	  validates_uniqueness_of :name
	  validates_duplicity_of :name, callback: :before_validation
	end

## Contributing

1. Fork it
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create new Pull Request
{'fraction_non_alphanumeric': 0.09563334536268495, 'fraction_numerical': 0.020570191266690727, 'mean_word_length': 4.191011235955056, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 13, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4452113', 'n_tokens_mistral': 1004, 'n_tokens_neox': 914, 'n_words': 313}