Last active
January 29, 2019 11:02
-
-
Save tbuehlmann/0c36c0ac0e81de8b20f54879d3e42227 to your computer and use it in GitHub Desktop.
This file contains 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 SomeModel < ApplicationRecord | |
after_initialize do | |
if new_record? | |
{some_attribute: 'default value'}.each do |attribute, value| | |
public_send("#{attribute}=", value) unless public_send(attribute) | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment