You''re right, that kind of logic is difficult to place. I have seen
one clean solution to this, though: Presenters
http://spin.atomicobject.com/2008/01/27/the-exceptional-presenter/
Jason
On Feb 11, 2008 7:40 AM, Toby Clemson
<tobyclemson-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:>
> Hi,
>
> I have a few cases where a particular value on a page should take 1 of
> 2 values and so at the top of the template I chose which:
>
> <%
> count = @count1 || @count2
> %>
> <%= count %>
>
> Often the decision between the two is a little more complicated e.g.,
> based on their values. The question is where should this sort of code
> go? In a helper? It is the controller that generates the instance
> variables @count1 and @count2 so it could very easily do the whole
> calculation and create another instance variable (both @count1 and
> @count2 are used elsewhere in the page so are still required). Or
> should this sort of thing be an attribute on a model?
>
> I am never sure where this sort of logic should go as it is kind of
> view logic and kind of business logic.
>
> Thanks in advance,
> Toby
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---