title: Key for mongoid model doesn't work
body: <p>I installed gem mongoid to RoR application, but received error "undefined method `key?' for nil:NilClass" while assign attribute to key function.</p>
  
  <p>So i have this model:</p>
  
  <pre><code> class Author
        include Mongoid::Document
        field :name
        key :name
      end
  </code></pre>
  
  <p>And default scaffold controller and running this url localhost:3000/authors , receive this error</p>
  
  <pre><code>NoMethodError in AuthorsController#index
  
  undefined method `key?' for nil:NilClass
  Rails.root: C:/Users/Jeremy/RubymineProjects/university
  </code></pre>
  
  <p>Gem file:</p>
  
  <pre><code>source 'https://rubygems.org'
  
  gem 'rails', '3.2.6'
  gem "mongoid", "~&gt; 3.0.0"
  gem "bson_ext", "~&gt; 1.2"
  
  group :assets do
    gem 'sass-rails',   '~&gt; 3.2.3'
    gem 'coffee-rails', '~&gt; 3.2.1'
    gem 'uglifier', '&gt;= 1.0.3'
  end
  
  gem 'jquery-rails'
  </code></pre>
  
  <p>I used guide from here <a href="http://railscasts.com/episodes/238-mongoid?view=asciicast" rel="noreferrer">http://railscasts.com/episodes/238-mongoid?view=asciicast</a>, did everything the same two times.</p>