How Would I Display Today's Posts Only?

I have a list of posts where I would simply like to display today’s post
entries only. I thought about using if-then statements, but is there a
better way to do it?

(As you can tell, I’m an ignorant noob :slight_smile:

On 17 Jun 2007, at 12:23, Bob S. wrote:

I have a list of posts where I would simply like to display today’s
post
entries only. I thought about using if-then statements, but is there a
better way to do it?

(As you can tell, I’m an ignorant noob :slight_smile:

What about in your Post model:

def self.todays_posts
self.find(:all, :conditions => [“post_date = ?”, Date.today])
end

Then in your controller:

def index
@posts = Post.todays_posts
end

And in your view:

<% @posts.each do |post| %>

<%= h post.title %>

<% end %>

Best regards

Peter De Berdt

Thanks, Peter!