Last active
December 16, 2015 14:09
-
-
Save rubyonrailstutor/5446652 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Company < ActiveRecord::Base | |
attr_accessible :cb_url, :name, :url | |
validates_presence_of :name, :cb_url | |
validates_uniqueness_of :name | |
has_many :events, :uniq => true | |
end | |
@records = Company.joins(:events).where(:events => { :date => ("2013-1-22")..("2013-3-22") } ).count | |
1.9.3p374 :002 > @records = Company.joins(:events).where(:events => { :date => ("2013-1-22")..("2013-3-22") } ).count | |
(4.7ms) SELECT COUNT(*) FROM "companies" INNER JOIN "events" ON "events"."company_id" = "companies"."id" WHERE ("events"."date" BETWEEN '2013-1-22' AND '2013-3-22') | |
=> 786 | |
#i'm getting 786 records but should only be getting 774, thoughts? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment