In my app I can add offers and give them a start and end date, the offers are displayed as partials. How can I go about only displaying them if the start date is todays date or earlier and the end date has not yet been reached?
So far I have:
offer partial
<% if offer.date_from > Date.today && offer.date_to < Date.today %>
<div class="offer_partial">
<div class="offer_title">
<%= offer.title %>
</div>
<div class="offer_body">
<%= offer.body %>
</div>
</div>
<% end %>
But this gives a undefined method `>' for nil:NilClass error.
Is it even ok to do these kind of checks in the view?
Thanks very much for any help!