Forum: Ruby on Rails uninitialized constant error, help me

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.
sukury47 (Guest)
on 2008-10-22 09:22
(Received via mailing list)
Hi, I'm a rails_fan in korea.

As korean web site has a little information about rails
I'm tryig to ask google groups users of my question



<% for reserve in @plan.reserves %>

This line make error like this 'uninitialized constant Plan::Reserf'

I already have plan and reserve model
and I define their relationship.

plan
 has_many :reserves

reserve
 belongs_to :plan

why does this error happen?
Craig D. (Guest)
on 2008-10-22 17:24
(Received via mailing list)
On Tue, Oct 21, 2008 at 11:06 AM, sukury47 
<removed_email_address@domain.invalid> wrote:

> reserve
>  belongs_to :plan
>
> why does this error happen?


First, check that your models are defined correctly.

* a Plan class defined in app/models/plan.rb

class Plan < ActiveRecord::Base
 has_many :reserves
end

* a Reserve class defined in app/models/reserve.rb

class Reserve < ActiveRecord::Base
 belongs_to :plan
end

Second, check the spelling: Reserf should be Reserve. Third, make sure
that
you do NOT define Reserve with a Plan namespace

class Plan::Reserve < ActiveRecord::Base
 belongs_to :plan
end

If you've defined Reserve like this, change it to the one shown above.

Those are some ideas for why you might be receiving that error. Please
let
us know if any of them help.

Regards,
Craig
This topic is locked and can not be replied to.