Last active
October 6, 2015 02:35
-
-
Save odigity/e33fd1b31fd26167a120 to your computer and use it in GitHub Desktop.
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
| class ModelBase | |
| # depends on Dirty plugin: http://www.rubydoc.info/gems/sequel/Sequel/Plugins/Dirty | |
| def validates_unchanged(attribute) | |
| errors.add(attribute, 'cannot be modified') if !new? and column_changed?(attribute) | |
| end | |
| end | |
| class Model < ModelBase | |
| def validate | |
| validates_unchanged :username | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment