Mike Wiesenhart Mike Wiesenhart - 2 months ago 5
SQL Question

Rails 4 hiding span in view

I have a span that will display when an open house is detected in the db using

<% if listing.open_houses.exists? %>
. I need it to not be displayed when the date/time has passed. I have a controller method that does that for the open house itself, but not sure how to do it for the span in the view. I included the controller code below as a reference. Thanks for any help!

Controller Method:

@open_houses = OpenHouse.upcoming.where(listing_id: @listing.id).where('open_houses.start_date >= ?', Date.current).order(start_date: :asc)


I was able to use<% if @open_houses.count >= 1 %>! Something small and silly that took me way too much time to figure out.