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
`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

class ProgramSpecificCategory < ActiveRecord::Base
  has_and_belongs_to_many :programs

I also have a common table:

    create_table :program_specific_categories_programs, :id => false do


      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.


seems to help a little, but still an error:

"undefined method `ProgramSpecificCategories' "


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

i.e def ProgramSpecificCategories

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.



it works, thank you.