Skip to content
This repository was archived by the owner on May 13, 2025. It is now read-only.

Conversation

@Velkitor
Copy link

@Velkitor Velkitor commented Mar 8, 2012

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"))

@adambair
Copy link
Contributor

adambair commented Mar 8, 2012

Thanks! I'll take a look at this later today -- Cheers!

Velkitor added 2 commits March 8, 2012 16:00
…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.
@thrillcall
Copy link

Any movement on adding this ability to the gem? This would be a great addition.

@delianides
Copy link

+1, @Velkitor your fork works really well! Thanks!

@Velkitor
Copy link
Author

Velkitor commented May 1, 2013

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants