I''m still new to rails and trying to figure out why this isn''t working. I''ve got a model named Buzzuser. It''s got an a boolean column/attribute named npc. At first I tried Buzzuser.find(:all, :conditions => ["npc = ?", true]) and got no results in the controller, but the same query executing in the console returned the correct row. Then I tried a simple Buzzuser.find(:all) with the same result: no results in controller, but correct in console. What am I missing? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Frederick Cheung
2008-Jun-12 14:26 UTC
Re: simple find works in console but not in controller
On 12 Jun 2008, at 15:17, Brian wrote:> > I''m still new to rails and trying to figure out why this isn''t > working. I''ve got a model named Buzzuser. It''s got an a boolean > column/attribute named npc. At first I tried > > Buzzuser.find(:all, :conditions => ["npc = ?", true]) > > and got no results in the controller, but the same query executing in > the console returned the correct row. Then I tried a simple > > Buzzuser.find(:all) > > with the same result: no results in controller, but correct in > console. >I expect they;re not running the same rails environment (check what it says when you run script/server and script/console) Fred> What am I missing? > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
I thought that too, but they''re both running in development environment. On Jun 12, 10:26 am, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On 12 Jun 2008, at 15:17, Brian wrote: > > > > > I''m still new to rails and trying to figure out why this isn''t > > working. I''ve got a model named Buzzuser. It''s got an a boolean > > column/attribute named npc. At first I tried > > > Buzzuser.find(:all, :conditions => ["npc = ?", true]) > > > and got no results in the controller, but the same query executing in > > the console returned the correct row. Then I tried a simple > > > Buzzuser.find(:all) > > > with the same result: no results in controller, but correct in > > console. > > I expect they;re not running the same rails environment (check what it > says when you run script/server and script/console) > > Fred > > > What am I missing?--~--~---------~--~----~------------~-------~--~----~ 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-Jun-12 14:46 UTC
Re: simple find works in console but not in controller
How does the SQL output look in development.log when you run in console and controller? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Brian wrote:> I thought that too, but they''re both running in development > environment.What do your unit tests reveal? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
I don''t know how to view the SQL in the console, but in the dev log it''s what I would expect: SELECT * FROM `buzzusers` for the Buzzuser.find(:all), and SELECT * FROM `buzzusers` WHERE (npc = 1) for Buzzuser.find(:all, :conditions => ["npc = ?", true]) On Jun 12, 10:46 am, Thorsten Müller <thors...-1oxKqHKwyltBDgjK7y7TUQ@public.gmane.org> wrote:> How does the SQL output look in development.log > when you run in console and controller?--~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Nothing. The unit test that runs this same find also successfully finds the 2 that were loaded via the fixture. On Jun 12, 10:48 am, Phlip <phlip2...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Brian wrote: > > I thought that too, but they''re both running in development > > environment. > > What do your unit tests reveal?--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
more strangeness : if I use the default scaffold views, I can see the buzzusers I''m looking for, and the npc = true values. But the find in the controller still doesn''t find them. Also, my current user (the standard restful_authentication user guy) has a :has_one relationship to a buzzuser, and that current buzzuser is being found just fine. Is there any way to get more information on what''s going on during the find operation? Could it be swallowing an error? Can I turn up the logging on it? On Jun 12, 10:26 am, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On 12 Jun 2008, at 15:17, Brian wrote: > > > > > I''m still new to rails and trying to figure out why this isn''t > > working. I''ve got a model named Buzzuser. It''s got an a boolean > > column/attribute named npc. At first I tried > > > Buzzuser.find(:all, :conditions => ["npc = ?", true]) > > > and got no results in the controller, but the same query executing in > > the console returned the correct row. Then I tried a simple > > > Buzzuser.find(:all) > > > with the same result: no results in controller, but correct in > > console. > > I expect they;re not running the same rails environment (check what it > says when you run script/server and script/console) > > Fred > > > What am I missing?--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---