# Logic and Syntax Help - Count

**URL:** <https://www.ruby-forum.com/t/logic-and-syntax-help-count/143303>\
**Category:** Rails\
**Created:** [July 17, 2008, 3:39am UTC](https://www.ruby-forum.com/t/logic-and-syntax-help-count/143303 "2008-07-17T03:39:13Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![KTKTKT](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/8797f3/32.png) [@KTKTKT](https://www.ruby-forum.com/u/KTKTKT)\
**Post date:** [July 17, 2008, 3:39am UTC](https://www.ruby-forum.com/t/logic-and-syntax-help-count/143303/1 "2008-07-17T03:39:13Z")

</div>

Given 3 tables: COURSES, REQUESTS, CLASSROOMS joined properly in the  
model (hopefully).

I want to either:

1. show all courses, but prohibit (onclick) enrollment in a course  
based on its classroom reaching capacity (static value in table per  
classroom).

Or, 2) do not show courses that have reached their classroom capacity  
through enrollment.

So, I think I have to count all requests for a given course, then show  
courses whose requestcount is \<= classroom.capacity.

Can anyone point me in the right direction on how to do this, and/or  
provide feedback on my logic? I’ll provide more details and code if  
you might find it useful…

Thanks in advance…
