# List animals with average capture\_percent (Josh Susser's example)

**URL:** <https://www.ruby-forum.com/t/list-animals-with-average-capture-percent-josh-sussers-example/138262>\
**Category:** Ruby\
**Created:** [May 21, 2008, 2:31pm UTC](https://www.ruby-forum.com/t/list-animals-with-average-capture-percent-josh-sussers-example/138262 "2008-05-21T14:31:02Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [May 21, 2008, 2:31pm UTC](https://www.ruby-forum.com/t/list-animals-with-average-capture-percent-josh-sussers-example/138262/1 "2008-05-21T14:31:02Z")

</div>

Hi guys,

I implemented self-referential system based on Josh S.'s guidance  
on [http://blog.hasmanythrough.com/2007/10/](http://blog.hasmanythrough.com/2007/10/) … ny-through

now I’m unsuccesfully trying to list all animals together with average  
hunt.capture\_percent, regardless of whether it is ‘pursuit’ or  
‘escape’ (i am using it on sthg else than animals where it makes sense  
not to differentiate between these. i want to keep having separated  
‘pursuit’ and ‘escape’ for future though)

i tried sthg like

\<%= (animal.pursuit.average(:capture\_percent)  
+animal.pursuit.average(:capture\_percent))/2 %\>

first, this doesn’t work, while having just \<%=  
(animal.pursuit.average(:capture\_percent) %\> does

second, i believe this calculation should rather be included in  
controller, but i have no idea how to do it over an array, join this  
array with the array of @animals and send this all to view ☹

this might be rather stupid newbie question, but I failed to google  
out an answer ☹ thanks for any help
