# Undefined method \`table\_name'

**URL:** <https://www.ruby-forum.com/t/undefined-method-table-name/143518>\
**Category:** Rails\
**Created:** [July 19, 2008, 10:29pm UTC](https://www.ruby-forum.com/t/undefined-method-table-name/143518 "2008-07-19T22:29:23Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [July 19, 2008, 10:29pm UTC](https://www.ruby-forum.com/t/undefined-method-table-name/143518/1 "2008-07-19T22:29:23Z")

</div>

Hi

I’m relative new to RoR - but I’m having a problem with some model  
relationships that I thought should have worked. Hope someone can  
help.

The code…

MODELS:

class Delivery \< ActiveRecord::Base  
belongs\_to :vehicle  
end

class Vehicle \< ActiveRecord::Base  
has\_many :deliveries

def self.find\_all\_active  
Vehicle.find(:all, :order =\> ‘name’, :conditions =\> [‘is\_active  
= ?’, true])  
end

end

CONTROLLER:  
@vehicles = Vehicle.find\_all\_active

VIEW:  
\<%= vehicle.deliveries.length %\>

The error…  
undefined method `table\_name’ for Delivery:Class

Notes…  
The problem seems to be the class method find\_all\_active. I tested the  
equivalent calls in the console and they work fine - so why not when  
the application is running?

Any comments appreciated

Thanks
