Guest User

Untitled

a guest
Jul 17th, 2018
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.35 KB | None | 0 0
  1. def self.count_habtm association
  2. output = {}
  3. self.count(:include => association.pluralize, :group => "#{association}_id").to_a.each do |a|
  4. #Ugly Ugly Ugly - I guess I'm missing something basic here
  5. label = eval(association.camelize).send("find",a[0].to_i).to_label if a[0]
  6. output[label] = a[1]
  7. end
  8. output
  9. end
  10. end
Add Comment
Please, Sign In to add comment