1. Computing & Technology

Discuss in my forum

Couldn't find without an ID

By , About.com Guide

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')

©2012 About.com. All rights reserved.

A part of The New York Times Company.