1. Technology
You can opt-out at any time. Please refer to our privacy policy for contact information.

Couldn't find without an ID


Problem: You've encountered the error message Couldn't find Page without an ID while trying to run find on an ActiveRecord class.

Solution: You more than likely forgot to pass the :all or :first parameter to the find method. The following would be incorrect.

links = Link.find(:conditions => 'mentioned > 0')

ActiveRecord needs to know whether you want the first thing it finds, or all things it finds. To fix this, do one of the following.

links = Link.find(:first, :conditions => 'mentioned > 0')
links = Link.find(:all, :conditions => 'mentioned > 0')
  1. About.com
  2. Technology
  3. Ruby
  4. Tutorials
  5. FAQs
  6. Error Messages: Couldn't find without an ID

©2014 About.com. All rights reserved.