Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module ValidAttributes
- def valid_attributes?(*args)
- attributes = [*args].flatten.map { |e| e.to_s }
- valid? || (errors.keys & attributes).empty?
- end
- module Errors
- delegate :keys, :to => '@errors'
- end
- end
- ActiveRecord::Base.send :include, ValidAttributes
- ActiveRecord::Errors.send :include, ValidAttributes::Errors
Add Comment
Please, Sign In to add comment