I'll have a look around and see whats going on... Many Thanks On 8 Dec, 21:29, Colin Law <[email protected]> wrote: > 2009/12/8 RubyonRails_newbie <[email protected]>: > > It is best not to top post, it is easier to follow the thread if > things are kept in order, I have reordered. > > > > > > > > > On 8 Dec, 21:08, Colin Law <[email protected]> wrote: > >> 2009/12/8 RubyonRails_newbie <[email protected]>: > > ... > >> > I looked on the rails api site, I was therefore kinda hoping that : > > >> > Post.find_by_user_id( session[:user_id], 1, :limit => > >> > 1, :conditions => "active_post = 1", :order => "created_at desc") > >> > would only return posts where the active flag is set to 1. > > >> I would kinda hope that would happen too. What did happen? > > >> Is active_post an integer type column or a string? If it is a string > >> then "active_post = '1'" might be better as integer 1 is not the same > >> as string '1' > > active_post is set as 'tinyint'. > > > What is currently happening is that I hit 'delete'.... > > What I meant was what does the the query > Post.find_by_user_id( session[:user_id], 1, :limit => 1, :conditions > => "active_post = 1", :order => "created_at desc") > return? > > If this returns a post with active_post not 1 then there is something > strange going on. Run it in a console window and see what it returns. > Also if you have not done so already work through the rails guide on > debugging. This will show you how using ruby-debug you can break in > (after that find for example) and see what it has returned. > > I have just looked at your code again and realised that I was looking > at the line before your call to fetchFirstPostForSessionUser, which is > not commented out but of course you are ignoring the return value. I > see that in fetchFirst.. you are using the condition with = 1 so it > should be ok. As I said try debugging and see what it is returning. > Also you can look in development.log and see exactly the query being > executed. > > Colin
-- 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 [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

