I''m trying to do a find with a particular condition. I have a runs table with a n_passed_steps column and an n_failed_steps column. I''m trying to do a find, to find all records, limited to the last 10, ordered by descending id, but with a pass percentage rate greater than 50%. So i''ve got the :all, :limit => 10, :order => ''id DESC'' bit, it''s just the :conditions bit I''m struggling with. The calculation is ((n_passed_steps/(n_passed_steps + n_failed_steps)) * 100) > 50 but if I simply insert that after :conditions, whether it be in ''quotes'' or [square brackets] I get an error. What is the correct way to go about this? -- 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 -~----------~----~----~----~------~----~------~--~---
HI Paul, What''s your error? Also, post to us the dbms you''re using and maybe the schema of your table (migration?) and the snippet being used for the find. We need more info in order to effectively help you! Regards, -- Peter Fitzgibbons ------------------------------ iPhone -- "IT"-ness. hrefhttp://www.macdailynews.com/index.php/weblog/comments/apples_iphone_could_become_iconic_it_object ------------------------------ On 7/12/07, Paul Nichols <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > > I''m trying to do a find with a particular condition. > > I have a runs table with a n_passed_steps column and an n_failed_steps > column. > > I''m trying to do a find, to find all records, limited to the last 10, > ordered by descending id, but with a pass percentage rate greater than > 50%. > > So i''ve got the :all, :limit => 10, :order => ''id DESC'' bit, it''s just > the :conditions bit I''m struggling with. > > The calculation is ((n_passed_steps/(n_passed_steps + n_failed_steps)) * > 100) > 50 but if I simply insert that after :conditions, whether it be > in ''quotes'' or [square brackets] I get an error. > > What is the correct way to go about this? > > -- > 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 -~----------~----~----~----~------~----~------~--~---
On Jul 12, 2007, at 5:12 AM, Paul Nichols wrote:> I''m trying to do a find with a particular condition. > > I have a runs table with a n_passed_steps column and an n_failed_steps > column. > > I''m trying to do a find, to find all records, limited to the last 10, > ordered by descending id, but with a pass percentage rate greater than > 50%. > > So i''ve got the :all, :limit => 10, :order => ''id DESC'' bit, it''s just > the :conditions bit I''m struggling with. > > The calculation is ((n_passed_steps/(n_passed_steps + > n_failed_steps)) * > 100) > 50 but if I simply insert that after :conditions, whether it be > in ''quotes'' or [square brackets] I get an error. > > What is the correct way to go about this?Don''t try so hard: :conditions => ''n_passed_steps > n_failed_steps'' -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 -~----------~----~----~----~------~----~------~--~---
Rob Biedenharn wrote:> On Jul 12, 2007, at 5:12 AM, Paul Nichols wrote: >> the :conditions bit I''m struggling with. >> >> The calculation is ((n_passed_steps/(n_passed_steps + >> n_failed_steps)) * >> 100) > 50 but if I simply insert that after :conditions, whether it be >> in ''quotes'' or [square brackets] I get an error. >> >> What is the correct way to go about this? > > Don''t try so hard: > > :conditions => ''n_passed_steps > n_failed_steps'' > > -Rob > > Rob Biedenharn http://agileconsultingllc.com > Rob-xa9cJyRlE0mWcWVYNo9pwxS2lgjeYSpx@public.gmane.orgThat''s so obvious now you mention it! However... the 50% figure was just as an example. Say I wanted to set the pass rate to something else? -- 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 -~----------~----~----~----~------~----~------~--~---
On Jul 13, 2007, at 4:51 AM, Paul Nichols wrote:> Rob Biedenharn wrote: >> On Jul 12, 2007, at 5:12 AM, Paul Nichols wrote: >>> the :conditions bit I''m struggling with. >>> >>> The calculation is ((n_passed_steps/(n_passed_steps + >>> n_failed_steps)) * >>> 100) > 50 but if I simply insert that after :conditions, whether >>> it be >>> in ''quotes'' or [square brackets] I get an error. >>> >>> What is the correct way to go about this? >> >> Don''t try so hard: >> >> :conditions => ''n_passed_steps > n_failed_steps'' >> >> -Rob >> >> Rob Biedenharn http://agileconsultingllc.com >> Rob-xa9cJyRlE0mWcWVYNo9pwxS2lgjeYSpx@public.gmane.org > > That''s so obvious now you mention it! > > However... the 50% figure was just as an example. Say I wanted to set > the pass rate to something else?Assuming: 0..100 === pass_rate, :conditions => [ ''(100.0 * n_passed_steps)/(n_passed_steps + n_failed_steps) > ?'', pass_rate ] -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 -~----------~----~----~----~------~----~------~--~---