1. Computing

Couldn't find without an ID

By

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. Computing
  3. Ruby
  4. Tutorials
  5. FAQs
  6. Error Messages: Couldn't find without an ID

©2014 About.com. All rights reserved.