title: Rails form params not being saved to database
body: <p>Rails newbie question...</p>
  
  <p>I have a form that is submitting without errors but the form params are not being saved to the database.  However, adding the data via rails console works fine.  Currently, when the form is submitted, the data is entered as nil into the db.</p>
  
  <p>Any feedback as to why this is happening would be very much appreciated. Also, pls note that the only two values I'm concerned with at this point for SuggestionBox are name and short_name.</p>
  
  <p>Thx in advance for any help!</p>
  
  <h2>Model</h2>
  
  <p>*Note: the only values I am concerned with at this point are name and short_name*</p>
  
  
  
  <pre class="lang-rb prettyprint-override"><code>            # == Schema Information
              #
              # Table name: suggestion_boxes
              #
              #  id              :integer          not null, primary key
              #  name            :string(255)
              #  created_at      :datetime         not null
              #  updated_at      :datetime         not null
              #  passcode        :string(255)
              #  suggestion_id   :integer
              #  organization_id :integer
              #  short_name      :string(255)
              #  owner_email     :string(255)
              #  owner_name      :string(255)
              #
  
              class SuggestionBox &lt; ActiveRecord::Base
                attr_accessible :name , :passcode, :short_name
                belongs_to :organization
                has_many :suggestions, :dependent =&gt; :destroy 
              end
  </code></pre>
  
  <h2>Controller</h2>
  
  <p>(I've only included the new and create actions)</p>
  
  <pre class="lang-rb prettyprint-override"><code>          class SuggestionBoxesController &lt; ApplicationController
  
              before_filter :authenticate
  
              def new
                @suggestion_box = SuggestionBox.new
  
                respond_to do |format|
                  format.html # new.html.erb
                  format.json { render json: @suggestion_box }
                end
              end
  
              def create
                @suggestion_box = SuggestionBox.new(params[:suggestion])
  
                respond_to do |format|
                  if @suggestion_box.save
                    format.html { redirect_to @suggestion_box, notice: "Your suggestion box has been created." }
                    format.json { render json: @suggestion_box, status: :created, location: @suggestion_box }
                  else
                    format.html { render action: "new" }
                    format.json { render json: @suggestion_box.errors, status: :unprocessable_entity }
                  end
                end
              end
            end
  </code></pre>
  
  <h2>View</h2>
  
  <p>This is the _form.html.erb file being used within new.html.erb</p>
  
  <pre class="lang-html prettyprint-override"><code>    &lt;%= form_for(@suggestion_box) do |f| %&gt;
        &lt;% if @suggestion_box.errors.any? %&gt;
          &lt;div id="error_explanation"&gt;
            &lt;h2&gt;&lt;%= pluralize(@suggestion_box.errors.count, "error") %&gt; prohibited this suggestion_box from being saved:&lt;/h2&gt;
  
            &lt;ul&gt;
            &lt;% @suggestion_box.errors.full_messages.each do |msg| %&gt;
              &lt;li&gt;&lt;%= msg %&gt;&lt;/li&gt;
            &lt;% end %&gt;
            &lt;/ul&gt;
          &lt;/div&gt;
        &lt;% end %&gt;
  
        &lt;div class="field"&gt;
          &lt;%= f.label :name %&gt;&lt;br /&gt;
          &lt;%= f.text_field :name %&gt;
        &lt;/div&gt;
          &lt;div class="field"&gt;
          &lt;%= f.label :short_name %&gt;&lt;br /&gt;
          &lt;%= f.text_field :short_name %&gt;
        &lt;/div&gt;
        &lt;div class="field"&gt;
          &lt;%= f.label :passcode %&gt;&lt;br /&gt;
          &lt;%= f.text_field :passcode %&gt;
        &lt;/div&gt;
        &lt;div class="actions"&gt;
          &lt;%= f.submit %&gt;
        &lt;/div&gt;
      &lt;% end %&gt;
  </code></pre>
  
  <h2>Rails Server Log (running on localhost)</h2>
  
  <p>This is the log output, showing nil values being added to the db for name and short_name.</p>
  
  <pre class="lang-rb prettyprint-override"><code>            Started GET "/suggestion_boxes/new" for 127.0.0.1 at 2013-07-29 12:34:23 -0400
              Processing by SuggestionBoxesController#new as HTML
                Rendered suggestion_boxes/_form.html.erb (164.7ms)
                Rendered suggestion_boxes/new.html.erb within layouts/application (166.6ms)
                Rendered layouts/_flashes.html.haml (0.2ms)
              Completed 200 OK in 175ms (Views: 173.9ms | ActiveRecord: 0.0ms)
  
  
              Started GET "/assets/screen.css?body=1" for 127.0.0.1 at 2013-07-29 12:34:23 -0400
              Served asset /screen.css - 304 Not Modified (0ms)
  
  
              Started POST "/suggestion_boxes" for 127.0.0.1 at 2013-07-29 12:34:40 -0400
              Processing by SuggestionBoxesController#create as HTML
                Parameters: {"utf8"=&gt;"✓", "authenticity_token"=&gt;"vpzqsKOA4PLgDJXgb8s28tktcXermcB/+CrQZNMhGCI=", "suggestion_box"=&gt;{"name"=&gt;"testy box", "short_name"=&gt;"tsty", "passcode"=&gt;"123"}, "commit"=&gt;"Create Suggestion box"}
                 (0.1ms)  begin transaction
                SQL (72.4ms)  INSERT INTO "suggestion_boxes" ("created_at", "name", "organization_id", "owner_email", "owner_name", "passcode", "short_name", "suggestion_id", "updated_at") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)  [["created_at", Mon, 29 Jul 2013 16:34:40 UTC +00:00], ["name", nil], ["organization_id", nil], ["owner_email", nil], ["owner_name", nil], ["passcode", nil], ["short_name", nil], ["suggestion_id", nil], ["updated_at", Mon, 29 Jul 2013 16:34:40 UTC +00:00]]
                 (3.3ms)  commit transaction
              Redirected to http://localhost:3000/suggestion_boxes/6
              Completed 302 Found in 82ms (ActiveRecord: 75.8ms)
  </code></pre>