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? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Johannes J. Schmidt
2008-Sep-23 15:29 UTC
Re: how to see stop the #<Outcome:0x371ace8> or the #
You want <%= debug your_code %> Greetings Johannes Am Dienstag, den 23.09.2008, 17:26 +0200 schrieb Brad Symons:> 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?--~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Thorsten Müller
2008-Sep-23 15:41 UTC
Re: how to see stop the #<Outcome:0x371ace8> or the #
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 --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Rob Biedenharn
2008-Sep-23 15:55 UTC
Re: how to see stop the #<Outcome:0x371ace8> or the #
On Sep 23, 2008, at 11:26 AM, Brad Symons wrote:> 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?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-xa9cJyRlE0mWcWVYNo9pwxS2lgjeYSpx@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
> 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]) -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Rob Biedenharn
2008-Sep-23 18:33 UTC
Re: how to see stop the #<Outcome:0x371ace8> or the #
On Sep 23, 2008, at 12:02 PM, Brad Symons wrote:>> 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-xa9cJyRlE0mWcWVYNo9pwxS2lgjeYSpx@public.gmane.org +1 513-295-4739 Skype: rob.biedenharn --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---