Created
December 16, 2009 09:19
-
-
Save lacco/257704 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
require 'factory_girl' | |
Dir["spec/factories/*"].each{|f| require f} | |
Factory.create :product | |
#=> new product with id=12 | |
Product.first.update_versioned(:charge_interval => 'daily') | |
#=> new product with id=13 | |
Product.all(:conditions => "id IN (select id from abstract_products group by name, edition having max(version))") | |
#=> Finds 12 instead of 13 | |
Product.all(:conditions => 'version = (SELECT MAX(version) FROM abstract_products AS inner_abstract_products WHERE inner_abstract_products.name = abstract_products.name)') | |
#=> Finds 13 correctly |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment