-
-
Save acook/5c6bec19d016fbf79762 to your computer and use it in GitHub Desktop.
Names changed to protect the guilty.
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 ThingyThing | |
include Virtus | |
extend ActiveModel::Naming | |
include ActiveModel::Validations | |
include ActiveModel::Conversion | |
attribute :thing, thing | |
def persisted? | |
false | |
end | |
validate do | |
unless thing.valid? | |
thing.errors.each do |key, value| | |
errors[key] << value | |
end | |
end | |
end | |
def save | |
unless valid? | |
Rails.logger.warn("ERROR - #{errors.inspect}") | |
return false | |
end | |
thing.save | |
rescue => e | |
Rails.logger.error "----------" | |
Rails.logger.error e | |
Rails.logger.warn("ERROR - #{errors.inspect}") | |
false | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment