Good question. I had exactly the same problem using Rails 3.1. Looks like you can not do this, because it does not work. Probably it is an intended behavior. Apparently, using polymorphic associations in combination with Single Table Inheritance (STI) in Rails is a bit complicated.
The current Rails documentation for Rails 3.2 gives this advice for combining polymorphic associations and STI:
Using polymorphic associations in combination with single table
inheritance (STI) is a little tricky. In order for the associations to
work as expected, ensure that you store the base model for the STI
models in the type column of the polymorphic association.
In your case the base model would be "Staff", i.e. "borrowable_type" should be "Staff" for all items, not "Guard". It is possible to make the derived class appear as the base class by using "becomes" : guard.becomes(Staff). One could set the column "borrowable_type" directly to the base class "Staff", or as the Rails Documentation suggests, convert it automatically using
class Car < ActiveRecord::Base
So that means you cannot associate a Car with a Guard and retrieve it with @guard.car, because the Car table will always have its 'borrowable_type' column set to 'Staff', and never to 'Guard'. And that means that polymorphic associations on STI models are completely useless.
It is possible, this answer worked for me. Mmmm... it is strange it doesn't work out of the box. I cant see why.
+1 for the link and description...
@dekeguard your statement regarding @guard.car is false. Using the solution provided, Rails transparently uses the STI base classname Staff as the target type and due to the fact that id's are always unique in an STI table it makes no difference whether the type is set to Guard or to Staff in the poly table the correct record will be fetched. Going from @car.guard will return the respective Guard too. So STI is useful with polymorphism because not only will the STI model work (with the provided solution) other models can still relate to the polymorphic model as well as desired.