bskaggs
1
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
is there just one way to get the value, which should just be a 1?
bskaggs
2
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
bskaggs
3
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.
bskaggs
4
You want <%= debug your_code %>
Greetings
Johannes
Am Dienstag, den 23.09.2008, 17:26 +0200 schrieb Brad S.:
bskaggs
5
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?
bskaggs
6
On Sep 23, 2008, at 11:26 AM, Brad S. wrote:
as:
#Outcome:0x371ace8
or if i remove the h above
is there just one way to get the value, which should just be a 1?
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 B. http://agileconsultingllc.com
[email protected]
bskaggs
7
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| %>
<%= link_to tc.number, {:controller =>
'testrun', :action => 'runtest', :id => tc.id, :id1 => @testrun, :id2 =>
@testsuite.id, :id3 => @version } -%> |
<% 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])
bskaggs
8
On Sep 23, 2008, at 12:02 PM, Brad S. wrote:
‘testrun’, :action => ‘runtest’, :id => tc.id, :id1 =>
@testrun, :id2 =>
@testsuite.id, :id3 => @version } -%>
<% end %>
<%= render :partial => ‘testcase’, :collection => @testsuite.testcases
%>
in app/views/{controller}/_testcase.rhtml
<%= link_to testcase.number, {:controller =>
'testrun', :action => 'runtest', :id => testcase.id, :id1 =>
@testrun, :id2 => testcase.testsuite_id, :id3 => @version } %>
<%=h testcase.description %>
<%=h testcase.status %>
<%=h testcase.last_run %>
If @testrun is an attribute of a testcase or testsuite, it should be
referenced that way.
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 B. http://agileconsultingllc.com
[email protected]
+1 513-295-4739
Skype: rob.biedenharn