Skip to content

Instantly share code, notes, and snippets.

@rab
Forked from dougalcorn/active_model_initialize.rb
Created December 30, 2010 22:09
Show Gist options
  • Save rab/760382 to your computer and use it in GitHub Desktop.
Save rab/760382 to your computer and use it in GitHub Desktop.
class Person
include ActiveModel::MassAssignmentSecurity
attr_accessor :name, :birthday, :handsomeness
attr_protected :handsomeness
def initialize(params = {})
self.attributes = params
end
def attributes=(params = {})
sanitize_for_mass_assignment(params).each do |k, v|
send("#{k}=", v)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment