create on a has_many through?

Hi, I have two models, User and Item, as well as a join model,
UserItem. So the User model includes the lines:

has_many :user_items
has_many :items, :through => :user_items

I've noticed that this doesn't work:

u =
u.items.create :name => "hammer"

Any reason why? Seems like it would be a nice feature. To get around
it, I usually do this:

u.items << Item.create :name => "hammer"
u.user_items.create(:item => User.create(:name => "hammer"))

Thanks for your time,


The reason this does not work is because your user object does not
exist in the database yet and there is no id to create the
association. either create or save the user first.

see the docs on why