<% for post in @posts do %>
Post Title: <%= post.title %> Date Ending:
<%= post.end_date %> <%= link_to 'View this post', :action
=> 'show', :id => post %>
<% end %>
Everything works great. But, I would like anything with an “end_date”
before today to not be displayed. I’m assuming I need to weasel now() in
there someplace, but I can’t figure out where.
In your controller add conditions to the paginate call: @post_pages, @posts = paginate(:posts, :conditons => ‘end_date >
CURRENT_DATE’,:per_page => 10, :order_by =>
‘end_date’)
—alternatively—
2)In the view you could do the following:
Posts ending soon
<% for post in @posts do %>
<% if post.end_date > now %>
Post Title: <%= post.title %> Date Ending:
<%= post.end_date %> <%= link_to 'View this post', :action
=> 'show', :id => post %>