# Portal behaviour - beginner question

**URL:** <https://www.ruby-forum.com/t/portal-behaviour-beginner-question/100291>\
**Category:** Rails\
**Created:** [February 2, 2006, 11:17am UTC](https://www.ruby-forum.com/t/portal-behaviour-beginner-question/100291 "2006-02-02T11:17:45Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![fred](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/db5fbb/32.png) [@fred](https://www.ruby-forum.com/u/fred)\
**Post date:** [February 2, 2006, 11:17am UTC](https://www.ruby-forum.com/t/portal-behaviour-beginner-question/100291/1 "2006-02-02T11:17:45Z")

</div>

Hello,

I’m still reading the Pragmatic pdf for ROR. I intend to port a small  
web-based soccer simulation game that a friend of mine wrote in php.

I still have in mind the basic cart application that can be found in the  
pdf. The main pages in the game typically display multiple statistical  
views (past games, player efficiency, …)

In my basic mind, this would involve calling multiple controllers and so  
on to fill the data required in the templates… but that seems just  
wrong to me… how would you do such a thing?

Best regards,

Fred

---

<div class="post-metadata">

**Author:** ![fred](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/db5fbb/32.png) [@fred](https://www.ruby-forum.com/u/fred)\
**Post date:** [February 2, 2006, 11:37am UTC](https://www.ruby-forum.com/t/portal-behaviour-beginner-question/100291/2 "2006-02-02T11:37:03Z")

</div>

> I still have in mind the basic cart application that can be found in the  
> pdf. The main pages in the game typically display multiple statistical  
> views (past games, player efficiency, …)
> 
> In my basic mind, this would involve calling multiple controllers and so  
> on to fill the data required in the templates… but that seems just  
> wrong to me… how would you do such a thing?

I would have a non-AR statistics class with one or more methods for each  
view. I’d instantiate that statistics model in the controller, and use  
render\_partial  
in the main view for each view.

Each view would reference the model, which would in turn compute the  
statistics and return the values for inclusion the template, which in  
turn  
would be rendered into the main view.

If the statistics could easily be grouped into AR models cleanly, then  
I’d  
consider using AR model methods instead of the non-AR class.

–  
– Tom M.

---

<div class="post-metadata">

**Author:** ![fred](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/db5fbb/32.png) [@fred](https://www.ruby-forum.com/u/fred)\
**Post date:** [February 3, 2006, 1:36pm UTC](https://www.ruby-forum.com/t/portal-behaviour-beginner-question/100291/3 "2006-02-03T13:36:50Z")

</div>

> I would have a non-AR statistics class with one or more methods for each  
> view. I’d instantiate that statistics model in the controller, and use  
> render\_partial  
> in the main view for each view.  
> forgive my stupidity, but what does AR stand for?

Fred

---

<div class="post-metadata">

**Author:** ![fred](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/db5fbb/32.png) [@fred](https://www.ruby-forum.com/u/fred)\
**Post date:** [February 3, 2006, 1:44pm UTC](https://www.ruby-forum.com/t/portal-behaviour-beginner-question/100291/4 "2006-02-03T13:44:22Z")

</div>

AR means active record, on the ror book the cart it implemented as a  
non AR class… If I rember well

–  
“The only thing necessary for the triumph of evil  
is for good men to do nothing”  
Edmund Burke

---

<div class="post-metadata">

**Author:** ![fred](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/db5fbb/32.png) [@fred](https://www.ruby-forum.com/u/fred)\
**Post date:** [February 6, 2006, 6:09pm UTC](https://www.ruby-forum.com/t/portal-behaviour-beginner-question/100291/5 "2006-02-06T18:09:30Z")

</div>

Now, assuming that I have multiple controllers that render in the same  
layout with statistics.  
To have those statistics computed, I guess I could set up filters on my  
controllers actions (to avoid having to explicitly call the computation  
methods).

Do you think there is any other/better way to do this?

(“statistics” might not have been the best word to express my needs, as,  
for instance, this could be a menu block, a quote-of-the-day block, …  
“Ã la” Xoops/PhpNuke/Zope/…)
