Last active
May 8, 2018 02:02
-
-
Save brunofrank/9712bbfbc50488e5bb031f5201025558 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ActiveRecord::Base | |
def self.has_custom_fields(store_at, *custom_fields) | |
custom_fields.each.each do |name| | |
define_method name do | |
self[store_at][name] | |
end | |
define_method "#{name}=" do |new_value| | |
self[store_at][name] = new_value | |
end | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Contact | |
has_custom_fields :custom_fields, :age, :fruta, :cor_do_cabelo | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment