Forum: Ruby on Rails uninitialized constant

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Joshua K. (Guest)
on 2006-02-02 07:38
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.
Wilson B. (Guest)
on 2006-02-02 07:47
(Received via mailing list)
On 2/2/06, Joshua K. <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.
Joshua K. (Guest)
on 2006-02-02 08:01
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). :)
This topic is locked and can not be replied to.