Skip to content

Instantly share code, notes, and snippets.

@scharfie
Created November 10, 2008 13:17
Show Gist options
  • Save scharfie/23487 to your computer and use it in GitHub Desktop.
Save scharfie/23487 to your computer and use it in GitHub Desktop.
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment