Guest User

Untitled

a guest
Feb 20th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.34 KB | None | 0 0
  1. module ValidAttributes
  2. def valid_attributes?(*args)
  3. attributes = [*args].flatten.map { |e| e.to_s }
  4. valid? || (errors.keys & attributes).empty?
  5. end
  6.  
  7. module Errors
  8. delegate :keys, :to => '@errors'
  9. end
  10. end
  11.  
  12. ActiveRecord::Base.send :include, ValidAttributes
  13. ActiveRecord::Errors.send :include, ValidAttributes::Errors
Add Comment
Please, Sign In to add comment