IDs being set incorrectly on a self-referential polymorphic join
===

Basic info: Rails 3.2.6 on Ruby 1.9.3-p194. I have a `User` model being joined with itself (and other models) via a polymorphic relationship with another model, `Like`. Here's what the classes look like:

    class User
      has_many :likes, :dependent => :destroy, :foreign_key => :user_id

      def like(obj)
        likes.create!(:likable_id => obj.id, :likable_type => obj.class.to_s)
      end
    end
    
    class Like
      belongs_to :user
      belongs_to :likable, :polymorphic => :true
    
      validates_uniqueness_of :user_id, :scope => [:likable_id, :likable_type]
    end

So the `like` method is set to create a Like specifically with likable_id and likable_type set to the argument's ID and class name. However, when going into console and having one user like another, the IDs end up being set incorrectly and the Like is created with the wrong parameters:

    1.9.3-p194> u1 = User.create
    1.9.3-p194> u2 = User.create
    1.9.3-p194> u1.like(u2)
    SQL (0.4ms)  INSERT INTO `likes` (`created_at`, `likable_id`,
    `likable_type`, `updated_at`, `user_id`) VALUES ('2012-07-25 16:20:42', 1,
    'User', '2012-07-25 16:20:42', NULL)

So for some reason, what ends up happening is that `user_id` is set to NULL instead of 1 and `likable_id` is set to 1 instead of 2.

I've tried messing around with the way the associations are defined (such as explicitly setting foreign keys), but nothing's really seemed to work. How can I get ActiveRecord to set the IDs correctly upon saving?