Tuesday, April 04, 2006

Migration Class and File naming

When running rake migrate I recently faced this output:

C:\work>rake migrate
(in C:/work)
rake aborted!
uninitialized constant CreateFooTable

(See full trace by running task with --trace)


Not the most informative message in the world. Running with trace didn't really help me out either. The error I made, on it's own, is fairly easy to spot, but I was also trying to load records of type Foo in this migration. Because I was trying to load records, I thought perhaps the error was occurring in the local definition of the Foo class.

Unfortunately, I missed the simple mistake. I had renamed the class to CreateFoosTable, because in Rails table names are plural.

Match the file name with the class name and everything works fine. A simple mistake that hopefully now we can both easily avoid in the future.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.