Craig, Also keep in mind that you should not put any kind of logic in the view, try to make your controller or a service do that for you.
Putting logic in the view will only cause problems in the feature. Try look at ViewModel Design Pattern On Wed, Dec 9, 2009 at 12:53 PM, RubyonRails_newbie < [email protected]> wrote: > I'll need to take another look at it. I dont think it's there, > > Would it look like select * from posts where active_post = 1? > > I'll take a closer look later.. > > Cheers Colin > > On 9 Dec, 14:23, Colin Law <[email protected]> wrote: > > 2009/12/9 RubyonRails_newbie <[email protected]>: > > > > > cool - i'll give this a go. I hope it's as simple as == instead of =. > > > > > Dev log showed my query as a select statement from posts, not > > > specifically looking at the active_post. > > > > Are you saying that the :conditions => "active_post = 1" is not in the > > actual query run? If so then that is the problem. Are you sure you > > are looking at the right bit of code? I think you need to debug the > > controller. > > > > Colin > > > > > > > > > > > > > will try a bit more.... :-) > > > > > cheers > > > > > On 9 Dec, 14:05, Colin Law <[email protected]> wrote: > > >> 2009/12/9 RubyonRails_newbie <[email protected]>: > > > > >> > Colin, > > > > >> > Before I debug.... I have had an idea: > > > > >> > What about the view? > > > > >> > If I can write a decent if statement to only return active_posts > that > > >> > = 1 I should be good to go. I did try this today, but it still > showed > > >> > the inactive post when I set it to 0.. > > > > >> > Here's what I wrote - There's maybe a better (correct way) to do > it... > > > > >> > <% if @posts.active_post = 1 %> > > > > >> That should be == 1 > > > > >> > <% render :partial => posts %> > > > > >> > <% end %> > > > > >> > <% if @posts.active_post != 1 %> > > > > >> You can use <% else %> rather then end and another if > > > > >> > There are no posts! > > > > >> > <% end %> > > > > >> > Sadly this didn’t work, but I wondered if anyone knew why? I can > > >> > delete a post, setting the 1 value to a 0, but the post still > remains > > >> > in the view… > > > > >> If still not working put in your view some debug: > > >> <p>posts active_post value is <%= @posts.active_post %></p> > > > > >> But you would be better off debugging the controller first to check > > >> that the query is working correctly. Did you look in development.log > > >> to see exactly what query is being run? > > > > >> 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]<rubyonrails-talk%[email protected]> > . > > > For more options, visit this group athttp:// > groups.google.com/group/rubyonrails-talk?hl=en.- Hide quoted text - > > > > - Show quoted text - > > -- > > 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]<rubyonrails-talk%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > > > -- 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.

