On 24 Sep 2008, at 09:56, Brad Symons wrote:

>
> Hi
>
> I am thinking about the design of my application, I understand its
> crucial to limit the amount of core code from the view.
>
> I seemed to have designed my app in a way found in an online tutorial,
> and am now encountering a few design issues.
>
> For example,
>
> my controllers seem to run along these lines:
>  #  testruns
>  def run
>    @testcase  = Testcase.find(:all)
>    @testsuite = Testsuite.find(params[:id])
>    @version   = Version.find(params[:id1])
>    @testruns  = Testrun.find(:all)
>    @testrun   = Testrun.find(:all).last.id
>  end
>
not relevant to this, but it's a bit wasteful to fetch all test runs  
just to get the id of the last one. I'd either use find :first, or in  
this case since you've already loaded them all anyway (although you  
don't seem to be using them) eg @testrun = @testruns.last.id

> and the view:
>
> <% @testsuite.testcases.each do |tc| %>
>  <tr>
>    <td align="left"><b><%= link_to tc.number, {:controller =>
> 'testrun', :action => 'runtest', :id => tc.id, :id1 =>  
> @testrun, :id2 =>
> @testsuite.id, :id3 => @version } -%> </b></td>
>
>    <td align="left"><b><%= tc.description -%></b></td>
>    <td align="left"><b><%= debug Result.find_by_resulttype(:all,
> :conditions => {:id => [1]}) %></b></td>
>    <td align="left"><b><%= @outcome.outcome_date %></b></td>
>  </tr>
> <% end %>
>
> The problem is, now I have to write some more detailed queries, like
> this for example:
> @passed    = Outcome.count(:all, :conditions =>  
> 'outcomes.outcome_date =
> (select max(o2.outcome_date) from outcomes o2 where o2.testrun_id =
> outcomes.testrun_id and o2.testcase_id = outcomes.testcase_id and
> outcomes.testrun_id = @testrun and outcomes.testcase_id = tc.id)')
>

something like that belongs in a model (perhaps an instance method of  
test run or something). pass any extra parameters in as parameters to  
that method

Fred


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to