Created
July 17, 2013 12:46
-
-
Save akishin/6020251 to your computer and use it in GitHub Desktop.
ActiveRecord read only model
This file contains 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
module Readonlyable | |
extend ActiveSupport::Concern | |
def readonly? | |
return true | |
end | |
def before_destroy | |
raise ActiveRecord::ReadOnlyRecord | |
end | |
module ClassMethods | |
def delete(id) | |
raise ActiveRecord::ReadOnlyRecord | |
end | |
def delete_all(conditions) | |
raise ActiveRecord::ReadOnlyRecord | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment