where I'm wrong? (has_and_belongs_to_many)

in the controller:

@program = Program.find_by_id(1)
@psc = ProgramSpecificCategory.find_by_id (2)
@program.ProgramSpecificCategories << @psc

fails with
"c:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:100:in
`const_missing': uninitialized constant Programspecificcategory"

Any idea what I'm missing? (completely newbie)

below are the components, if it helps:

class Program < ActiveRecord::Base
  has_and_belongs_to_many :programspecificcategories
end

class ProgramSpecificCategory < ActiveRecord::Base
  has_and_belongs_to_many :programs
end

I also have a common table:

    create_table :program_specific_categories_programs, :id => false do

t>

      t.column :program_id, :integer, :limit =>11
      t.column :programspecificcategory_id, :integer, :limit =>11

has_and_belongs_to_many :program_specific_categories

Mind the under_scores.

Max

seems to help a little, but still an error:

"undefined method `ProgramSpecificCategories' "

@program.ProgramSpecificCategories

when you say this it means that there is a method by that name

i.e def ProgramSpecificCategories
#…
end

but here thats not the case so what you want to put inside the instance variables of @program try to fill in those data i.e the columns of the underlying table

what i think you want to do from the code it seems

More under_scores:

@program.ProgramSpecificCategories << @psc

should be

@program.program_specific_categories << @psc

and in your migration:

t.column :programspecificcategory_id, :integer, :limit =>11

should be

t.column :program_specific_category_id, :integer, :limit =>11

In Rails, the naming convention is that *only* class names are
upeer/camel cased. Everything else (and I mean everything) is
snake_cased, including table names, column names, methods names and
field names.

Cheers,
Max

YES!

it works, thank you.