Forum: Ruby on Rails sql logic is killing me

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
C1e5a9e9344b6d31b9df7303e6dc378a?d=identicon&s=25 Craig White (Guest)
on 2006-02-18 05:36
(Received via mailing list)
I know my thinking is sloppy.

I want to know how many clients currently in my facility are male...

My facilities_controller.rb

  def list_fac
    @placement_pages, @placements = paginate(
      :placements,
      :conditions => ["placements.facility_id = ?",
        params[:facility_id] ],
      :include => [:facility, :client],
      :order_by => 'facilities.name, clients.last_name,
      :per_page => 14)
    @facility = Facility.find(:first,
      :conditions => ["id = ?", params[:facility_id] ])
    @beds_total = @facility.beds_m + @facility.beds_f + @facility.beds_a
    @beds_m_cnt = Client.count_by_sql("select count(*) " +
      " from clients where sex = 'M' ")
  end

the @beds_m_cnt gives me count of all Male clients but I only need the
ones in @placements which I can't seem to use in the @beds_m_cnt
assignment. Is this an issue of iteration that I don't understand or
logic which I apparently don't have?

Help?

Craig
C1e5a9e9344b6d31b9df7303e6dc378a?d=identicon&s=25 Craig White (Guest)
on 2006-02-18 07:34
(Received via mailing list)
Please ignore - I actually figured it out myself...I did have to
iterate.

Thanks

Craig
This topic is locked and can not be replied to.