title: Error: When assigning attributes, you must pass a hash as an argument
body: <p>Hi ive just started with ruby and i was writing the controller and controller spec but i have some problems. </p>
  
  <p>document.rb</p>
  
  <pre><code>class Document &lt; ActiveRecord::Base
    validates_presence_of :name
    has_many :votes
  end
  </code></pre>
  
  <p>documents_controller.rb </p>
  
  <pre><code>class API::DocumentsController &lt; ApplicationController
    def create
      @document = Document.new(:name)
      if @document.save
        @document.update_attributes(name: @document.name.url) if document_params[:name].present?
        render json: @document, serializer: DocumentSerializer, status: 201
      else
        render json: @document.errors, status: 422
      end
    end
  end
  </code></pre>
  
  <p>documents_controller_spec.rb</p>
  
  <pre><code>  describe "POST 'index'" do
      before { @attr = FactoryGirl.attributes_for(:document) }
  
      describe "failure" do
        describe "with missing parameters" do
          before { @attr.each { |key,value| @attr[key] = nil } }
          it "should not create a new record" do
            lambda { post :create, document: @attr }.should_not change(Document, :count)
          end
        end
      end
    end
  </code></pre>
  
  <p>however, when i ran <code>bundle exec rspec spec</code> to try out my tests i got an error:</p>
  
  <pre><code>Failure/Error: lambda { post :create, document: @attr }.should_not change(Document, :count)                                                                                                                                                                                  
       ArgumentError:                                                                                                                                                                                                                                                               
         When assigning attributes, you must pass a hash as an argument.                                                                                                                                                                                                            
       # ./app/controllers/api/documents_controller.rb:8:in `create'                                                                                                                                                                                                                
       # ./spec/controllers/api/documents_controller_spec.rb:29:in `block (6 levels) in &lt;top (required)&gt;'                                                                                                                                                                           
       # ./spec/controllers/api/documents_controller_spec.rb:29:in `block (5 levels) in &lt;top (required)&gt;'
  </code></pre>
  
  <p>Can anyone shed some light on this?</p>