This repository was archived by the owner on May 13, 2025. It is now read-only.
Added the ability to add and remove from the gem's distributed dictionary.#9
Open
Velkitor wants to merge 5 commits intomobomo:masterfrom
Open
Added the ability to add and remove from the gem's distributed dictionary.#9Velkitor wants to merge 5 commits intomobomo:masterfrom
Velkitor wants to merge 5 commits intomobomo:masterfrom
Conversation
…remove_from_dictionary method.
Contributor
|
Thanks! I'll take a look at this later today -- Cheers! |
…ecord 3.2.x seems to look for methods named after attributes, and use those values during the save. The unbind_profanity and bind_profanity methods are instance methods so they will not effect other instances of the class. ActiveRecord seems to gather the attributes prior to calling before_save so I had to override the save method, and call my before/after methods by hand.
…return that result back from our overriden method.
|
Any movement on adding this ability to the gem? This would be a great addition. |
|
+1, @Velkitor your fork works really well! Thanks! |
Author
|
Thanks @delianides. We had some requirements on our site that needed custom additions etc to the base profanity filter. I also had to add some before/after save stuff to handle a change in behavior of active record that we noticed when we moved rails versions. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The following functions have been added to the ProfanityFilter::Base:
append_dictionary( ) - This will load the supplied yml file and merge it with the existing dictionary.
remove_from_dictionary( ) - This will load the supplied yml file and remove the keys in the supplied yml file from the current dictionary.
Example initializer for a Rails project:
profanity.rb:
ProfanityFilter::Base.append_dictionary(File.join(Rails.root,"/config/profanity.yml"))
ProfanityFilter::Base.remove_from_dictionary(File.join(Rails.root,"/config/profanity_exclude.yml"))