Q:

Rails: ActiveRecord class throws "NameError: uninitialized constant" - Is this a naming issue? 

I have a model file called:
r_i_o_modules_and_instrument.rb

...which contains something like this...
class RIOModulesAndInstrument < ActiveRecord::Base
  belongs_to :parentmodel
  attr_accessible :attribute_1, :attribute_2, :attribute_3
end

The corresponding MySQL table name is:
 r_i_o_modules_and_instruments

But: In the cosole, from...
> RIOModulesAndInstrument.count

...I get:
NameError: uninitialized constant RIOModulesAndInstrument

Does anybody have a clue what the problem is and ways to solve it? ( Is it a naming restriction problem?) 
Thanks a lot for helping out! 

A:

Try this:
Change your model file name to rio_modules_and_instrument.rb
In model rio_modules_and_instrument.rb
class RIOModulesAndInstrument < ActiveRecord::Base
  set_table_name "r_i_o_modules_and_instruments" #if you are using rails v > 3.1.0 use self.table_name = "r_i_o_modules_and_instruments"
  belongs_to :parentmodel
  attr_accessible :attribute_1, :attribute_2, :attribute_3
end

