Hi. I have tables for users and items. I''m trying to make a query that will find all of the items belonging to the current user. I have a testuser with id = 1 and this user has 4 items. If I use the line: @items = Item.find(:all, :conditions => "user_id = 1" ) The four items are displayed no problem. However if I use: @items = Item.find(:all, :conditions => "user_id ''session[:user][:id]''" ) or @sid = session[:user][:id] @items = Item.find(:all, :conditions => "user_id = @sid" ) No results are returned I have tried printing out the value of session[:user][:id] on the results page and it displays correctly as 1. Can anyone tell me where I''m going wrong? Thanks. -- 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. I have tables for users and items. I''m trying to make a query that > will find all of the items belonging to the current user. > I have a testuser with id = 1 and this user has 4 items. > > If I use the line: > @items = Item.find(:all, :conditions => "user_id = 1" ) > The four items are displayed no problem. > > However if I use: > @items = Item.find(:all, :conditions => "user_id > ''session[:user][:id]''" ) > or > @sid = session[:user][:id] > @items = Item.find(:all, :conditions => "user_id = @sid" )@items = Item.find(:all, :conditions => ["user_id = ?", session[:user][:id]]) -philip> > No results are returned > > I have tried printing out the value of session[:user][:id] on the > results page and it displays correctly as 1. > > Can anyone tell me where I''m going wrong? > > Thanks. > -- > 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 -~----------~----~----~----~------~----~------~--~---
Thanks, if works now! -- 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 -~----------~----~----~----~------~----~------~--~---