title: "undefined method `metadata' for.." rails
body: <p>Hi i have this problem running the spec file.
  this is the reparator model:</p>
  
  <pre><code>class Reparator &lt; User
    include Mongoid::Document
    include Mongoid::Timestamps
    field :private_reparator, :type =&gt; Boolean, :default =&gt; true
    field :brand_name, :type =&gt; String
    field :year_of_experience, :type =&gt; Integer, :default =&gt; 1
  
    has_many :reparations
    has_many :skills
  
    validates_presence_of :skills, :year_of_experience
    validates :year_of_experience, :numericality =&gt; {:greater_than_or_equal_to =&gt; 0}
  end
  </code></pre>
  
  <p>This is the skill model:</p>
  
  <pre><code>class Skill
    include Mongoid::Document
  
    field :name, :type =&gt; String
  
    belongs_to :reparator
  
    validates_presence_of :name
    validates_uniqueness_of :name
  
  end
  </code></pre>
  
  <p>This is the controller:</p>
  
  <pre><code>class ReparatorsController &lt; ApplicationController
    respond_to :json
  
    def index
      @reparators = Reparator.all
      respond_with @reparators
    end
  
    def show
      @reparator = Reparator.find(params[:id])
      respond_with @reparator
    end
  
    def create
      @reparator = Reparator.new(params[:reparator])
      @reparator.skills = params[:skills]
      if @reparator.save
        respond_with @reparator
      else
        respond_with @reparator.errors
      end
    end
  
    def update
      @reparator = Reparator.find(params[:id])
  
      if @reparator.update_attributes(params[:reparator])
        respond_with @reparator
      else
        respond_with @reparator.errors
      end
    end
  
    def destroy
      @reparator = Reparator.find(params[:id])
      @reparator.destroy
      respond_with "Correctly destroyed"
    end
  
  end
  </code></pre>
  
  <p>And this is the spec file for this controller (i'll just put the test that does't pass):</p>
  
  <pre><code>it "Should create an reparator" do
        valid_skills = [FactoryGirl.create(:skill).id, FactoryGirl.create(:skill).id]
        valid_attributes = {:name =&gt; "Vianello",
                            :email =&gt; "maremma@gmail.com",
                            :address =&gt; "viale ciccio",
                            :private_reparator =&gt; true
                            }
        post :create, :reparator =&gt; valid_attributes, :skills =&gt; valid_skills
        assigns(:reparator).should be_a Reparator
        assigns(:reparator).should be_persisted
      end
  </code></pre>
  
  <p>And this is the skill Factory girl:</p>
  
  <pre><code>FactoryGirl.define do
    factory :skill do
      sequence(:name) {|n| "skill#{n}"}
    end
  end
  </code></pre>