I'm building a custom profile completeness tool in Rails 3.1. Using active_admin, the administrator wants to be able to pick model attributes and assign a score value to them. I create a table with 'name' and 'score' in it. The name being the column name to apply the score to.
I need to compare the values from the name column in the scoring table when the model gets updated. Psuedocode:
ProfileScore.find(:all, :select => "name,score").inject { |p,score|
#this is where im stuck, 'self' == updated model hash
p[:name] == self.attribute.updated
score += p[:score]
}
Of course other approaches are welcome! I looked at completeness-fu but it is way out of date.