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.