Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ruby on Rails ActiveRecord: pluralization

I'm new to Rails, so forgive my ignorance of ActiveRecord. One of my models is named "campus". I ran the migration and it pluralized everything except "campus".

I thought that was lame so I added the code to the environment config to leave everything singular.

I deleted the tables, manually edited the migration files to use singular forms, and re-ran the migrations. Now my associations to "campus" no longer work. I ran it through the console and noticed that I'm getting an uninitialized constant "Campu". So something still thinks "campus" is plural? Should I assume that config change will cause me nothing but trouble going forward?

like image 797
Donald Hughes Avatar asked Feb 28 '10 04:02

Donald Hughes


1 Answers

Use custom inflections. See this related question: How do I override rails naming conventions?

like image 199
Jimmy Avatar answered Sep 27 '22 20:09

Jimmy