Guest User

Untitled

a guest
Apr 26th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. require 'factory_girl'
  2. Dir["spec/factories/*"].each{|f| require f}
  3. Factory.create :product
  4. #=> new product with id=12
  5. Product.first.update_versioned(:charge_interval => 'daily')
  6. #=> new product with id=13
  7. Product.all(:conditions => "id IN (select id from abstract_products group by name, edition having max(version))")
  8. #=> Finds 12 instead of 13
  9. Product.all(:conditions => 'version = (SELECT MAX(version) FROM abstract_products AS inner_abstract_products WHERE inner_abstract_products.name = abstract_products.name)')
  10. #=> Finds 13 correctly
Add Comment
Please, Sign In to add comment