0

Whats up with this model names in rails ?, Why is this not working ?

rails g model a_b_c name:text

rake db:migrate

rails c

ABC

NameError: uninitialized constant ABC

Now, any sane person would ask me, why I would create a model a_b_c?. Thats exactly not what im doing.

I have 50 models named, books_f1_availabilities..books_f50_availabilities.

Now, there is one model in which I have to specify a relationship for books_availabilities to a vendor, so when I rename, books_f10_availabilities to books_v_f10_availabilities, I get an error like mentioned above, when I access that model in rails console by,

BooksVF10Availabilities

NameError: uninitialized constant BooksVF10Availabilities

Please advice.

beck03076
  • 3,268
  • 2
  • 27
  • 37
  • Have you renamed your model to BooksF10Availabilities to BooksVF10Availabilities – naren Apr 23 '12 at 19:11
  • 1
    No, I see where you are getting at. I totally understand that, the model name should be equal_to table_name.camelize. I think its a rails Convention Over Configuration stuff. – beck03076 Apr 23 '12 at 22:56
  • In the model file books_v_f10_availabilities.rb the name should be class BooksVF10Availabilities – naren Apr 23 '12 at 23:02
  • It is "BooksVF10Availabilities". There is something else to this! – beck03076 Apr 24 '12 at 06:42
  • No, I changed books_v_f10_availabilities.rb to books_vendors_f10_availabilities.rb.. – beck03076 Apr 24 '12 at 16:40
  • I assume it is some naming convention problem.. I am not sure where exactly it was wrong. If this is not a private project and if you can share it on github may be I can try to have look at it – naren Apr 24 '12 at 16:54
  • Its ok. Thanks for your interest, though! – beck03076 Apr 24 '12 at 17:01

0 Answers0