title: Cakephp 2.2.3 habtm saving to intermediary table
body: <p>Alright, so for my project in Cakephp 2.2.3, I setup my database and controllers and baked everything. I double checked it all and its all working (add, edit, delete). The one thing I cannot get working is saving to the intermediary table between the <code>users</code> table and a <code>websites</code> table. The intermediary table is <code>user_websites</code>. The <code>user_websites</code> table only has 3 fields: <code>id</code>, <code>user_id</code>, and <code>website_id</code>.</p>
  
  <p>When I login as a registered user and go to the websites add page, I can add the website no problem, but it only saves to the <code>websites</code> table and nothing in the <code>user_websites</code> table. Fiddling with the add function in the <code>WebsitesController</code> I can get it to save the <code>website_id</code> in the <code>user_websites</code> table but again, nothing for the <code>user_id</code>. What I need to have happen, obviously, is when adding a new website it should save that record to the <code>websites</code> table, and add a record to the <code>user_websites</code> table with the current logged in user's id and the <code>website_id</code> that was just saved. Any help would be appreciated. Thanks!</p>
  
  <p>Here's my code:</p>
  
  <h3>User Model</h3>
  
  <pre><code>public $hasMany = array(
      'UserWebsite' =&gt; array(
      'className' =&gt; 'UserWebsite',
      'foreignKey' =&gt; 'user_id',
      'dependent' =&gt; false,
      'conditions' =&gt; '',
      'fields' =&gt; '',
      'order' =&gt; '',
      'limit' =&gt; '',
      'offset' =&gt; '',
      'exclusive' =&gt; '',
      'finderQuery' =&gt; '',
      'counterQuery' =&gt; ''
      )
  );
  </code></pre>
  
  <h3>Website Model</h3>
  
  <pre><code>public $hasMany = array(
      'UserWebsite' =&gt; array(
          'className' =&gt; 'UserWebsite',
          'foreignKey' =&gt; 'user_id',
          'dependent' =&gt; false,
          'conditions' =&gt; '',
          'fields' =&gt; '',
          'order' =&gt; '',
          'limit' =&gt; '',
          'offset' =&gt; '',
          'exclusive' =&gt; '',
          'finderQuery' =&gt; '',
          'counterQuery' =&gt; ''
      )
  );
  
  public $hasAndBelongsToMany = array(
      'User' =&gt; array(
          'className' =&gt; 'User',
          'joinTable' =&gt; 'users_websites',
          'foreignKey' =&gt; 'website_id',
          'associationForeignKey' =&gt; 'user_id',
          'unique' =&gt; 'keepExisting',
          'conditions' =&gt; '',
          'fields' =&gt; '',
          'order' =&gt; '',
          'limit' =&gt; '',
          'offset' =&gt; '',
          'finderQuery' =&gt; '',
          'deleteQuery' =&gt; '',
          'insertQuery' =&gt; ''
      )
  );
  </code></pre>
  
  <h3>UserWebsite Model</h3>
  
  <pre><code>public $belongsTo = array(
      'User' =&gt; array(
          'className' =&gt; 'User',
          'foreignKey' =&gt; 'user_id',
          'conditions' =&gt; '',
          'fields' =&gt; '',
          'order' =&gt; ''
      ),
      'Website' =&gt; array(
          'className' =&gt; 'Website',
          'foreignKey' =&gt; 'website_id',
          'conditions' =&gt; '',
          'fields' =&gt; '',
          'order' =&gt; ''
      )
  );
  </code></pre>
  
  <h3>WebsitesController</h3>
  
  <pre><code>public function add() {
      if ($this-&gt;request-&gt;is('post')) {
  
          $this-&gt;Website-&gt;create();
          if ($this-&gt;Website-&gt;UserWebsite-&gt;saveAll($this-&gt;request-&gt;data, array('deep' =&gt; true))) { 
      $log = $this-&gt;Website-&gt;getDataSource()-&gt;getLog(false, false);
      debug($log);
              $this-&gt;Session-&gt;setFlash(__('The website has been saved'));
              $this-&gt;redirect(array('action' =&gt; 'index'));
          } else {
              $this-&gt;Session-&gt;setFlash(__('The website could not be saved. Please, try again.'));
          }
      }
  
  }
  </code></pre>