Helper help

T

Tomasz Tomczyk

I need a helper, which will render a table in my customized style.
I wrote a code like this:

template.rhtml:
<% @column_names = ["Name", "Age", "Sex"] %>
<%= table_show @column_name %>

helper.rb
def table_show(names)
for name in names
content_tag ( :div, name, :class => 'table_header' )
end
end

Which should give me an output like this:
<div class='table_header'>Name</div>
<div class='table_header'>Age</div>
<div class='table_header'>Sex</div>

Unfortunately I have only one line of output which looks like:
NameAgeSex

After few trials it seems, that this output is being generated by line:
"for name in names", because deleting "content_tag..." doesn't make any
differences.

What am I doing wrong?
I suppose that helper def does treat an Array like a String...

Regards,
Tomasz Tomczyk
 
P

Phrogz

I need a helper, which will render a table in my customized style.
[snip]

You will probably get a better response if you ask this on the Ruby on
Rails mailing list. The Ruby-talk mailing list (and forum, and
comp.lang.ruby newsgroup) is primarily for discussion of the Ruby
language itself, not the Ruby on Rails web framework that happens to
use it.

http://groups.google.com/group/rubyonrails-talk
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,159
Messages
2,570,879
Members
47,413
Latest member
ReeceDorri

Latest Threads

Top