Sure,
>From what you've written, it looks like your event model has
attributes called dreq_reqno, dreq_status and dreq_create_time and
you've joined these together with the event_detail method.
If this is the case, you could add a method in on of your helper files
(probably EventsHelper) that will build a table for you with all of
the desired columns and rows.
Here's an example:
def events_table(events)
concat "<table>" # concat is equivelant to puts in this case
for event in events do
concat "<tr>" # you can write html tags or use the rails view
helpers
concat content_tag(:td, event.attribute_1) # the first columns
attribute
concat content_tag(:td, event.attribute_2) # the second columns
attribute
concat "</tr>
end
concat "</table>"
nil # important to return nil at the end of the helper method
end
Writing html in a helper using the concat method can get a little
messy though. I would use a gem/plugin called markaby here as it's
much cleaner.
http://railscasts.com/episodes/69-markaby-in-helper
when adding a table in your view, you'd simply use <%= events_table
(@events) %>
Thinking about it, this would probably be easier in a parial:
# parial called events
<% content_tag :table do %>
<% for event in events do %>
<% content_tag :tr do %>
<%= content_tag :td, event.attribute_1 %>
... etc
<% end %>
<% end %>
<% end %>
Then call <%= render :partial => 'events', :object => @events %> from
your view.
Gav
--~--~---------~--~----~------------~-------~--~----~
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 [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---