title: Rails - tracking bookings on an event site
body: <p>I'm building an events site using Rails. I need to create a system that monitors the number of bookings being taken to ensure an Event does not become over-subscribed. What is the most effective (DRY) way to do this? On my index page I have each event listed with a main image, event title and date. I also want to include a tracking message illustrating how many spaces are left e.g "50 spaces left - book now".</p>
  
  <p>I've tried this code in my bookings controller but it doesn't work - </p>
  
  <pre><code>if @event.bookings.count &gt;= @event.number_of_spaces
          flash[:warning] = "Sorry, this event is fully booked."
          redirect_to root_path
  
  
      end
  </code></pre>
  
  <p>Is there a more effective method to do this? I have a Booking MVC set up. </p>