title: Save object from form to DB
body: <p>I have a model:</p>
  
  <pre><code>class Scr &lt; ActiveRecord::Base
    def self.find_scrs
      find(:all, :order =&gt; "id")
    end
  end
  </code></pre>
  
  <p>View (form):</p>
  
  <pre><code>&lt;div class="scr-form"&gt;
   &lt;fieldset&gt;
     &lt;% form_for :scr, :url =&gt; { :action =&gt; :save_scr } do |form| %&gt;
     &lt;p&gt; 
       &lt;label for="scr_id"&gt;Id:&lt;/label&gt;
       &lt;%= form.text_field :id, :size =&gt; 40 %&gt;
     &lt;/p&gt;
     &lt;p&gt; 
       &lt;label for="scr_description"&gt;Description:&lt;/label&gt;
       &lt;%= form.text_area :description, :rows =&gt; 3, :cols =&gt; 40 %&gt;
     &lt;/p&gt;
  
     &lt;%= submit_tag "Save", :class =&gt; "submit" %&gt;
     &lt;% end %&gt;
   &lt;/fieldset&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>And controller:</p>
  
  <pre><code>class InboxController &lt; ApplicationController
    def index
     @scrs = Scr.find_scrs
   end
  
   def add_scr
   end  
  
   def save_scr
     @src = Scr.new(params[:scr])
     puts "=============================="
     @a = params[:scr]
     puts @a
     puts "=============================="
     @scr.save
   end
  end
  </code></pre>
  
  <p>I fill the fields in the form, press Save button and get error:</p>
  
  <pre><code>You have a nil object when you didn't expect it!
  You might have expected an instance of ActiveRecord::Base.
  The error occurred while evaluating nil.save
  
  
  /home/demas/artefacts/dev/study/ruby/rails/tracker/app/controllers/inbox_controller.rb:15:in `save_scr'
  /usr/lib/ruby/gems/1.9.1/gems/actionpack-2.3.8/lib/action_controller/base.rb:1331:in `perform_action'
  /usr/lib/ruby/gems/1.9.1/gems/actionpack-2.3.8/lib/action_controller/filters.rb:617:in `call_filters'
  ...
  
   Request
   Parameters
   {"authenticity_token"=&gt;"m/QBN85+5Kj+Qewtl29mBl5kBtSBr1+Ixv4jxTq6Rfk=",
   "scr"=&gt;{"id"=&gt;"as",
   "description"=&gt;"sa"},
   "commit"=&gt;"Save"}
  </code></pre>
  
  <p>As i see Rails can not create the instance of Scr class.  Why?</p>