-
Notifications
You must be signed in to change notification settings - Fork 0
Programmatic Changes
- Home – Summary and Installation instructions
- Model Usage – How to include blacklist validation in your model
- Blacklist Syntax – How to setup your blacklist yaml files, with the various options
- Programmatic Changes – Changing your blacklists programmatically
Before you read about updating your blacklists programmatically, it’s important to understand that the application will be updating your yaml files. I chose not to store blacklists in the database to simplify the gem, and its usage by the developer. I wanted a yaml file so blacklists would be easy to edit by hand. But I also allow you to edit them from within the code. This means the YAML library will be reading and writing to the blacklist files. This may cause some YAML reformatting in the files themselves, but everything will still work.
More importantly, you’re not just applying changes to this session – it’s for the entire application.
# with the default message
User.blacklist(:name, 'Veronica')
# with a custom message #
User.blacklist(:name, 'Stinky Pete', 'smells funny')
This is the same as adding – if the blacklist value already exists, the error message will be updated.
User.unblacklist(:name, 'Stinky Pete')