how to see stop the #<Outcome:0x371ace8> or the #

i am using the following:

<%= h Outcome.find(: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 = ? and outcomes.testcase_id = ?', @testrun, tc.id])
%>

which is working fine, but as usual in the browser the value appears as:

#<Outcome:0x371ace8>

or if i remove the h above

You want <%= debug your_code %>

Greetings
Johannes

this would depend, on what exactly you want to display.

Outcome.find(:all, ...)

will retrieve a set of records and <Outcome:0x371ace8> is
the internal id of that.

do you want the size? then use
Outcome.find(:all, ...).size

or should it return only one record and you want the id column?
Outcome.find(:first, ...).id

would do that (or replace "id" with any column name you want

hi

i want to retrive the value its searching for, which is the result_id
column in the outcomes table.

using

Outcome.find(:first, ...).result_id

i get this >

You have a nil object when you didn't expect it!
The error occurred while evaluating nil.result_id

if i change that to .id

i get 289986 which is a non existent record in the db.

Ignoring the presence of so much code in a view, you can define Outcome#to_s to get a customized output for an Outcome object.

-Rob

Rob Biedenharn http://agileconsultingllc.com
Rob@AgileConsultingLLC.com

with the debug option, the string appears like this:

- !ruby/object:Outcome
  attributes:
    result_id: "1"
    testrun_id: "34"
    testcase_id: "1"
    id: "42"
    outcome_date: 2008-09-23 15:58:35
  attributes_cache: {}

result_id is CORRECT
testrun_id is CORRECT
testcase_id is CORRECT
id is CORRECT
outcome_date is CORRECT

but essentially its not returning the result_id???

but how do i get it to return the result_id?

Ignoring the presence of so much code in a view>>

yes i totally agree, but i cant quite figure out how to keep it in the
controller.

because i need to use the tc.id, thats taken from the following loop

<% @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>
  </tr>
<% end %>

any suggestions would be great, basically its iterating over a list.

test.rhtml
(tc.id)
\
TC# DESC STATUS LAST RUN
1
2
3

controller.rb
@testcase = Testcase.find(:all)
@testsuite = Testsuite.find(params[:id])

Ignoring the presence of so much code in a view>>

yes i totally agree, but i cant quite figure out how to keep it in the
controller.

because i need to use the tc.id, thats taken from the following loop

<% @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>
</tr>
<% end %>

<%= render :partial => 'testcase', :collection => @testsuite.testcases %>

in app/views/{controller}/_testcase.rhtml
<tr>
   <td align="left"><b><%= link_to testcase.number, {:controller => 'testrun', :action => 'runtest', :id => testcase.id, :id1 => @testrun, :id2 => testcase.testsuite_id, :id3 => @version } %></b></td>
   <td><%=h testcase.description %></td>
   <td><%=h testcase.status %></td>
   <td><%=h testcase.last_run %></td>
</tr>

If @testrun is an attribute of a testcase or testsuite, it should be referenced that way.

any suggestions would be great, basically its iterating over a list.

test.rhtml
(tc.id)
\
TC# DESC STATUS LAST RUN
1
2
3

controller.rb
@testcase = Testcase.find(:all)
@testsuite = Testsuite.find(params[:id])

Shouldn't @testcase be plural? And if you really mean @testsuite.testcases, it doesn't need to be its own instance variable.

-Rob

Rob Biedenharn http://agileconsultingllc.com
Rob@AgileConsultingLLC.com
+1 513-295-4739
Skype: rob.biedenharn