2009/12/8 RubyonRails_newbie <[email protected]>: > Hi there, > > I've decided that instead of deleting all posts on a user's profile, > there is now an active_post column in the posts table. > > Basically, a user has only 1 active post at a time, and the database > is either a value of 0 (inactive) or 1(active) > > I have a problem though. When i add a post, I see that the active > column is set to 1. > When I add a 2nd post, the most recent is set to active_post = 1 and > the initial post is set to 0. (this is as i expect). > > However - if I delete a post using the link on the page, the database > value sets to 0 (also what I want and expect) > > But - the last post is still displayed on the page. > > Below is the code on the posts controller, that hopefully explains > what I'm doing: > > Basically - does anyone know how to hide this post? (as it stands the > posts for this user are inactive, so should not be visible to them) > > I think it's to do with the :conditions. > > def index > �...@posts = Post.find_by_user_id( session[:user_id], :order => > "created_at DESC") > Post.find_by_user_id( session[:user_id], 1, :limit => > 1, :conditions => "active_post", :order => "created_at desc")
Can you explain what :conditions => "active_post" is supposed to do? Possibly you should be comparing the value of active_post with some value? 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.

