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
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
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
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!
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs