title: Why does this return Nil in Ruby on Rails 3?
body: <p>I ran this command:</p>
  
  <pre><code>user1 = User.create(:email =&gt; 'test12@abc.com', :password =&gt; 'test12123', :username =&gt; 'test12', :first_name =&gt; 'Test', :last_name =&gt; 'User', :plan_id =&gt; '4')
  </code></pre>
  
  <p>and got this error:</p>
  
  <pre><code>NoMethodError: undefined method `trial_duration' for nil:NilClass
  </code></pre>
  
  <p>This is my User model:</p>
  
  <pre><code># == Schema Information
  # Schema version: 20110412170916
  #
  # Table name: users
  #
  #  id                   :integer         not null, primary key
  #  email                :string(255)
  #  encrypted_password   :string(128)
  #  password_salt        :string(255)
  #  reset_password_token :string(255)
  #  remember_token       :string(255)
  #  remember_created_at  :datetime
  #  sign_in_count        :integer
  #  current_sign_in_at   :datetime
  #  last_sign_in_at      :datetime
  #  current_sign_in_ip   :string(255)
  #  last_sign_in_ip      :string(255)
  #  username             :string(255)
  #  first_name           :string(255)
  #  last_name            :string(255)
  #  created_at           :datetime
  #  updated_at           :datetime
  #  invitation_token     :string(60)
  #  invitation_sent_at   :datetime
  #  plan_id              :integer
  #  current_state        :string(255)
  #  confirmation_token   :string(255)
  #  confirmed_at         :datetime
  #  confirmation_sent_at :datetime
  #  space_used           :integer         default(0), not null
  #  failed_attempts      :integer         default(0)
  #  unlock_token         :string(255)
  #  locked_at            :datetime
  #  trial_end_date       :date
  #  active_subscription  :boolean
  #
  
  belongs_to :plan
  
  before_create :set_trial_end
  
  def set_trial_end
       plan = self.plan
       end_of_trial = self.created_at + plan.trial_duration.days
       self.trial_end_date = end_of_trial
  end
  </code></pre>
  
  <p>This is my Plan model:</p>
  
  <pre><code># == Schema Information
  # Schema version: 20110412101615
  #
  # Table name: plans
  #
  #  id                  :integer         not null, primary key
  #  name                :string(255)
  #  storage             :float
  #  num_of_projects     :integer
  #  num_of_clients      :integer
  #  cached_slug         :string(255)
  #  created_at          :datetime
  #  updated_at          :datetime
  #  amount              :integer
  #  trial_duration      :integer
  #  trial_duration_unit :string(255)
  #  currency            :string(255)
  #  billing_cycle       :integer
  #  billing_cycle_unit  :string(255)
  #
  
  class Plan &lt; ActiveRecord::Base
  
    has_many  :users
      has_many    :subscriptions
      has_friendly_id :name, :use_slug =&gt; true
  
  end
  </code></pre>
  
  <p>Thoughts ?</p>