# bug report

**URL:** <https://discuss.rubyonrails.org/t/bug-report/30330>\
**Category:** rubyonrails-talk\
**Created:** [June 6, 2008, 6:43pm UTC](https://discuss.rubyonrails.org/t/bug-report/30330 "2008-06-06T18:43:02Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![11175](https://avatars.discourse-cdn.com/v4/letter/1/8edcca/32.png) [@11175](https://discuss.rubyonrails.org/u/11175)\
**Post date:** [June 6, 2008, 6:43pm UTC](https://discuss.rubyonrails.org/t/bug-report/30330/1 "2008-06-06T18:43:02Z")

</div>

I assume this is a bug with find :last?

> > capella.ps.last

=\> #\<Program id: 888, name: "Post-... deleted\_reason: nil\> # worked

> > capella.ps.find :last

ActiveRecord::RecordNotFound: Couldn't find Program with ID=6329 AND (programs.school\_id = 6) &nbsp;&nbsp;from /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active\_record/base.rb:1267:in `find_one' &nbsp;&nbsp;from /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/base.rb:1250:in `find\_from\_ids\_without\_coercion' &nbsp;&nbsp;from /Users/rogerpack/dev/degreesearch/vendor/plugins/acts\_as\_sluggable/lib/active\_record\_overrides.rb:12:in `find_from_ids' &nbsp;&nbsp;from /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/base.rb:504:in `find' &nbsp;&nbsp;from /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active\_record/associations/has\_many\_association.rb:66:in `find' &nbsp;&nbsp;from (irb):7

🙂Before I submit it wanted to check.

-R

---

<div class="post-metadata">

**Author:** ![Frederick\_Cheung](https://sea2.discourse-cdn.com/rubyonrails/user_avatar/discuss.rubyonrails.org/frederick_cheung/32/3901_2.png) [@Frederick\_Cheung](https://discuss.rubyonrails.org/u/Frederick_Cheung)\
**Post date:** [June 7, 2008, 9:35am UTC](https://discuss.rubyonrails.org/t/bug-report/30330/2 "2008-06-07T09:35:42Z")

</div>

Nope it's because you're running rails 2.0.2, which doesn't have find :last. capella.ps.last works but that's an array.last (ie the same as [1,2,3,4].last: it's loading the whole array and then returning the last element

Fred

---

<div class="post-metadata">

**Author:** ![Sheldon\_Hearn3](https://avatars.discourse-cdn.com/v4/letter/s/bcef8e/32.png) [@Sheldon\_Hearn3](https://discuss.rubyonrails.org/u/Sheldon_Hearn3)\
**Post date:** [June 7, 2008, 12:11pm UTC](https://discuss.rubyonrails.org/t/bug-report/30330/3 "2008-06-07T12:11:37Z")

</div>

Instead, do

capella.ps.find :first, :order =\> "id DESC"

Which item is "last" in a SQL query depends on what you're ordering the query on, so you could use created\_at or something else instead of id.

Ciao, Sheldon.
