From: Bauduin Raphael Date: 2004-08-14T22:31:05+09:00 Subject: Rails helper working with template Hi, I'm trying to develop a Rails component to display a Ruby array as a html table (which could evolve in something equivalent to CKHTMLTable for cgikit). I use a helper: #Helper method that can be used in the main template: def html_table(ar) @working_array = ar render("htmltable") end and here's the template rendered by the helper method: #template used by the helper (htmltable): <%for a in @working_array %> <%for element in a%> <%end%> <%end%>
<%=element%>
That enables me to do this <%=html_table(@list)%> in my application template, and will display the array @list as html table. The problem is that the working_array variable has to be used as instance variable, possibly introducing naming collisions.... Is there a nice solution to this? Or could a new render_* method be helpful, using all variables available where it is called (even non instance variables)? Thanks. Raph PS: not that I want to reopen the debate there was when comparing cgikit and rails, but isn't the binding file preventing such naming collisions?