title: Rails attributes not being saved
body: <p>When trying to save a new entity (<code>Vote</code>) with AJAX calls, but the attributes are not being assigned.</p>
  
  <p>Class and method being used:</p>
  
  <pre><code>class VoteController &lt; ApplicationController
      respond_to :json
  
      def vote
          question_id = params[:question][:id]
          user_id = current_user.id
          vote = Vote.where(["question_id = :q", { q: question_id }]).where(["user_id = :u", { u: user_id }]).take
          respond_with do |format|
              if vote.nil?
                  @vote = Vote.new
                  @vote.question = question_id
                  @vote.user = user_id
                  @vote.save
                  format.json { render :json =&gt; { :status =&gt; 'ok' } }
              else            
                  format.json { render :json =&gt; { :status =&gt; 'failed', :msg =&gt; 'You already voted' } }
              end
          end
      end
  end
  </code></pre>
  
  <p>The model:</p>
  
  <pre><code>class Vote &lt; ActiveRecord::Base
      belongs_to :user
      belongs_to :question
  
      attr_accessor :user, :question
  end
  </code></pre>
  
  <p>And the migration:</p>
  
  <pre><code>class CreateVotes &lt; ActiveRecord::Migration
    def change
      create_table :votes do |t|
          t.references :question
          t.references :user
      end
    end
  end
  </code></pre>
  
  <p>These are the parameters that are being sent:</p>
  
  <pre><code>Parameters: {"utf8"=&gt;"✓", "question"=&gt;{"id"=&gt;"1"}, "commit"=&gt;"Up vote"}
  </code></pre>
  
  <p>With <code>puts</code> I tested that <code>current_user.id</code> indeed returns a value.</p>
  
  <p>And here the query that is executed:</p>
  
  <pre><code>INSERT INTO `votes` VALUES ()
  </code></pre>
  
  <p>My records in the database:</p>
  
  <pre><code>+----+-------------+---------+
  | id | question_id | user_id |
  +----+-------------+---------+
  |  1 |        NULL |    NULL |
  |  2 |        NULL |    NULL |
  |  3 |        NULL |    NULL |
  |  4 |        NULL |    NULL |
  |  5 |        NULL |    NULL |
  |  6 |        NULL |    NULL |
  |  7 |        NULL |    NULL |
  +----+-------------+---------+
  </code></pre>
  
  <p>Why aren't these attributes being assigned?</p>