alphagov/whitehall — pull request #603 by matthewford (2013-06-14 09:45:14+00:00)
Title: Fix errors being raised by searching when index is out of date

irb(main):003:0> Edition.where(id: [99999])
Edition Load (0.8ms) SELECT `editions`.* FROM `editions` WHERE `editions`.`id` IN (99999) AND (`editions`.`state` != 'deleted')
=> []

vs

irb(main):004:0> Edition.find([99999])
Edition Load (0.4ms) SELECT `editions`.* FROM `editions` WHERE `editions`.`id` = 99999 AND (`editions`.`state` != 'deleted') LIMIT 1
ActiveRecord::RecordNotFound: Couldn't find Edition with id=99999 [WHERE (`editions`.`state` != 'deleted')]
from /var/lib/gems/1.9.1/gems/activerecord-3.1.12/lib/active_record/relation/finder_methods.rb:339:in `find_one'
from /var/lib/gems/1.9.1/gems/activerecord-3.1.12/lib/active_record/relation/finder_methods.rb:310:in `find_with_ids'
from /var/lib/gems/1.9.1/gems/activerecord-3.1.12/lib/active_record/relation/finder_methods.rb:107:in `find'
from /var/lib/gems/1.9.1/gems/activerecord-3.1.12/lib/active_record/base.rb:441:in `find'
from (irb):4
from /var/lib/gems/1.9.1/gems/railties-3.1.12/lib/rails/commands/console.rb:45:in `start'
from /var/lib/gems/1.9.1/gems/railties-3.1.12/lib/rails/commands/console.rb:8:in `start'
from /var/lib/gems/1.9.1/gems/railties-3.1.12/lib/rails/commands.rb:40:in `'
from script/rails:6:in `require'
from script/rails:6:in `

'