Re: [Rails] Re: Strategies for streamlining view code

2009-11-19 Thread tramuntanal
2009/11/19 pharrington > > For simple cases you could just create a helper like this: > def admin_only &blk > yield if current_user.admin? > end > > <% admin_only do %> > some ISH > <% end %> > > or a helper like: def show_user_info if (current_user.admin?) do 'User is admin.' elsif (c

[Rails] Re: Strategies for streamlining view code

2009-11-19 Thread Andi Schacke
Definitely take a look at Florian Hanke's representer-plugin at http://github.com/floere/representer. It gives you the ability to have 'object oriented' views. You put all the logic (conditionals etc.) inside methods of the view-object. Much much easier to test and it results in extra clean views.

[Rails] Re: Strategies for streamlining view code

2009-11-18 Thread pharrington
On Nov 18, 4:29 pm, ressister wrote: > I am working on a project that uses quite a bit of conditional logic > to display information about groups in a list.  The partial that > renders the group attributes will display different info based on > whether the user is a) logged in, b) the creator of t