Skip to content

Instantly share code, notes, and snippets.

@chsh
Last active October 3, 2015 02:28
Show Gist options
  • Save chsh/2372574 to your computer and use it in GitHub Desktop.
Save chsh/2372574 to your computer and use it in GitHub Desktop.
It's my reminder. I always forget this. ;-)
class NonActiveRecordModel
include ActiveModel::Validations
include ActiveModel::Conversion
extend ActiveModel::Naming
def persisted?; false end
def initialize(hash = {})
hash.each do |key, value|
m = "#{key}="
self.send(m, value) if self.respond_to?(m)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment