Shoulda Doesn’t like ‘Status’
One of the models in a project I am working on right now ends in 'status'. Rails handles that just find but in my tests I started noticing an odd error:
test: Lookup should belong_to lookup_status. (LookupTest):
NameError: uninitialized constant LookupStatu
The Shoulda test looks like this:
should_belong_to :lookup_status
Nothing to complicated there. Should recognizes the relationship just find but when it tries to find a class it goes looking for LookupStatu. I fixed this by adding the the class name to the relationship thus:
belongs_to :lookup_status, :class_name => 'LookupStatus'
Justin Ball is a software consultant and entrepreneur with a passion for Ruby. He evolved from a C++ and .Net monkey into a python programmer and finally found Ruby. In the rare moments when he isn't writing code, talking about code or measuring his code productivity in profanity per hour, you can find him on his bike in the mountains or on the roads surrounding Cache Valley. 









