Skip to content

Instantly share code, notes, and snippets.

@mxrguspxrt
Created September 6, 2012 18:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mxrguspxrt/3659304 to your computer and use it in GitHub Desktop.
Save mxrguspxrt/3659304 to your computer and use it in GitHub Desktop.
Rails Tableless
class Tableless
extend ActiveModel::Naming
extend ActiveModel::Translation
include ActiveModel::Validations
include ActiveModel::Conversion
include ActiveModel::MassAssignmentSecurity
def initialize(params={})
if params
sanitized_params = sanitize_for_mass_assignment(params)
sanitized_params.each do |attr, value|
self.public_send("#{attr}=", value)
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment