Hi,
I’ve got a little Rails app, and I wanted to generate a report from
some data. I did it one way, but it didn’t seem quite “Rails”.
I created two methods in a controller, one called “report” that was
empty:
def report
end
that would just then display the report.rhtml page. This page
contained a form tag with a text box and a submit button. This form
then submitted to a “do_report” method in the controller:
def do_report
teams = … etc
end
This then displayed a do_report.rhtml which formatted the output.
I thought I would try to streamline it a bit, and moved the code in
do_report into the report method, and had the and had the form submit
directly to the “report” method and used:
if request.post? …
…
end
to only generate the report data if it was posted.
I also removed the do_report.rhtml file, and moved it’s code into the
report.rhtml file, but surrounded the reporting section with
<% if … %>
…
<% end %>
This seems kludgy to me and was wondering how others have handled
this. The separate “report” and “do_report” seem even more cumbersome.
Does anyone have any hints/suggestions/sample code?
Thanks!
jt