'Find' not working with array of ID's
Reported by soccer022483 (at gmail) | June 30th, 2009 @ 12:27 PM
Order.pickable.collect(&:id) => [2, 3, 6, 9, 14] Order.pickable.find([2,3]) ActiveRecord::RecordNotFound: Couldn't find all Orders with IDs (2, 3)
AND (found 0 results, but was looking for 2)from.../vendor/plugins/friendly_id/lib/friendly_id/sluggable_class_methods.rb:72:in
find_some'
====================================
After commenting out has_friendly_id
Order.pickable.find([2,3]).size => 2
Comments and changes to this ticket
-
Norman Clarke June 30th, 2009 @ 04:45 PM
- → State changed from new to hold
I added a test to friendly_id to attempt to reproduce this behavior but I'm unable to reproduce the error. Can you share with me your model's migration, named scope code and some sample data?
-

Donald Ball July 24th, 2009 @ 01:10 PM
I ran into this recently. Turns out the models didn't have slugs as they were being bootstrapped by populate.
Still, this could be considered a bug, in that the SQL to load, say, Order.find([1, 2]) ends up being:
SELECT orders.* FROM
ordersINNER JOINslugsONslugs.sluggable_id =orders.id ANDslugs.sluggable_type = 'Order' WHERE (orders.id IN (1,2) OR slugs.id IN (null))The IN (null) condition is of dubious utility and the INNER JOIN is of course throwing away valid orders.
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
Friendly_id is a plugin for Ruby on Rails which allows you to work with human-friendly strings as well as numeric ids in ActiveRecord models.
