uninitialized constant error, help me

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?

First, check that your models are defined correctly.

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

class Plan < ActiveRecord::Base has_many :reserves


  • 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