# Uninitialized constant

**URL:** <https://www.ruby-forum.com/t/uninitialized-constant/53355>\
**Category:** Rails\
**Created:** [February 2, 2006, 6:38am UTC](https://www.ruby-forum.com/t/uninitialized-constant/53355 "2006-02-02T06:38:21Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jkahn](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/53a042/32.png) [@jkahn](https://www.ruby-forum.com/u/jkahn)\
**Post date:** [February 2, 2006, 6:38am UTC](https://www.ruby-forum.com/t/uninitialized-constant/53355/1 "2006-02-02T06:38:21Z")

</div>

Ok, I searched but couldn’t find anything and I even tried the RoR IRC  
channel with no help.

I get this error:

uninitialized constant Airport

I used this code which I got from the RoR site.

helper :sorting

def list  
@sorter = SortingHelper::Sorter.new self, %w(icao host\_id name),  
@params[‘sort’], @params[‘order’], ‘icao’, ‘ASC’  
@pages = Paginator.new self, Airport.count, 10, @params[‘page’]  
@airports = Airport.find\_all nil, @sorter.to\_sql,  
@pages.current.to\_sql

render\_action ‘none’ if 0 == @airports.length  
end

Can anyone help? If you need more information I will give it if I can.

BTW, I’m a RoR newbie so if this is something really simple, I’m sorry.

---

<div class="post-metadata">

**Author:** ![jkahn](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/53a042/32.png) [@jkahn](https://www.ruby-forum.com/u/jkahn)\
**Post date:** [February 2, 2006, 6:47am UTC](https://www.ruby-forum.com/t/uninitialized-constant/53355/2 "2006-02-02T06:47:51Z")

</div>

On 2/2/06, Joshua K. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Can anyone help? If you need more information I will give it if I can.
> 
> BTW, I’m a RoR newbie so if this is something really simple, I’m sorry.

Try putting “model :airport” on the line above “helper :sorting”

That shouldn’t be necessary if the Airport model is in  
app/models/airport.rb, or if this controller is called “Airports” or  
“Airport”, but it will probably fix it.

–Wilson.

---

<div class="post-metadata">

**Author:** ![jkahn](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/53a042/32.png) [@jkahn](https://www.ruby-forum.com/u/jkahn)\
**Post date:** [February 2, 2006, 7:01am UTC](https://www.ruby-forum.com/t/uninitialized-constant/53355/3 "2006-02-02T07:01:04Z")

</div>

Thanks Wilson, but just by dumb luck I figured it out.

I replaced my list with:

def list  
@sorter = SortingHelper::Sorter.new self, %w(event course  
section date), @params[‘sort’], @params[‘order’], ‘date’, ‘ASC’  
@pages = Paginator.new self, Dates.count, 10, @params[‘page’]  
@dates = Dates.find\_all nil, @sorter.to\_sql, @pages.current.to\_sql  
render\_action ‘none’ if 0 == @dates.length  
end

It was a stupid mistake of not realizing that I needed to change  
Airport(s) to Date(s). 🙂
