rails 数据库的 `:building` 列中没有保存数据?

No data is being save in `:building` column of rails database?

我创建了一个 valuation table 其中包含

class CreateValuations < ActiveRecord::Migration
  def change
    create_table :valuations do |t|
      t.text :location
      t.integer :number_of_bedroom
      t.integer :number_of_bath
      t.integer :age_of_building
      t.text :other_details
      t.string :name
      t.string :email
      t.integer :contact_number

      t.timestamps null: false
   end
 end

结束

后来我使用 rails generate migration add_building_to_valuations building:text 在其中添加了文本类型的列 :building。我创建了一个表格

<div class="row">
    <div class="col-md-6 col-md-offset-3">
        <%= form_for(@valuation) do |val| %>

            <%= val.label :building, "Name of Building/Builder" %>
            <%= val.text_field :building, class: 'form-control' %>

            <%= val.label :location, "Location" %>
            <%= val.text_field :location, class: 'form-control' %>

            <%= val.label :number_of_bedroom, "Number of Bedroom" %>
            <%= val.text_field :number_of_bedroom, class: 'form-control' %>

            <%= val.label :number_of_washroom, "Number of Washroom" %>
            <%= val.text_field :number_of_bath, class: 'form-control' %>

            <%= val.label :age_of_building, "Age of Building" %>
            <%= val.text_field :age_of_building, class: 'form-control' %>

            <%= val.label :name, "Name" %>
            <%= val.text_field :name, class: 'form-control' %>

            <%= val.label :email, "Email" %>
            <%= val.text_field :email, class: 'form-control' %>

            <%= val.label :contact_number, "Contact Number" %>
            <%= val.text_field :contact_number, class: 'form-control' %>

            <%= val.submit "Evaluate my property", class: "btn btn-primary" %>

        <% end %>
    </div>
</div>

当我填写所有字段并通过 Evaluate my property 提交时,:building 中没有数据被保存。

我使用以下命令检查了这个 $ rails console $ Valuation.all

并且接收到的输出在输出

之后
#<Valuation id: 1, location: "Chandivali, Powai", 
number_of_bedroom: 3, number_of_bath: 3, 
age_of_building: 9, other_details: nil, name: "Shravan", 
email: "shravan.xxx@gmail.com", 
contact_number: "9876543210",created_at: "2015-11-14 09:47:26",
updated_at: "2015-11-14 09:47:26", building: nil>,

您应该更新您的 valuation_params 这很可能是私有函数

private
    def valuation_params
        params.require(:valuation).permit(:building,
                 :location,
                 :number_of_bedroom, 
                 :number_of_bath, 
                 :age_of_building, 
                 :name, :email, :contact_number)
    end
end