Created
October 10, 2013 23:39
-
-
Save cwoodcox/6927382 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
# Create the associations for individual body_metrics and accept their nested | |
# attributes. This makes the biometrics form work and a few other things. | |
Dir['app/models/body_metric/*.rb'].collect { |file| File.basename(file).sub /\.rb/, '' }.each do |metric| | |
has_one :"current_#{metric}", -> { latest }, class_name: "BodyMetric::#{metric.camelize}" | |
accepts_nested_attributes_for :"current_#{metric}" | |
define_method("current_#{metric}") do | |
super() || self.send(:"build_current_#{metric}") | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment