【发布时间】:2014-08-28 03:02:56
【问题描述】:
当我点击提交时,参数和所有数据一起显示,然而,当我保存时,它显示为:
SQL (1.0ms) INSERT INTO `billings` (`birth`, `city`, `country`, `created_at`, `gender`, `ictype`, `idno`, `marital`, `name`, `national`, `phone`, `postcode`, `race`, `reference_id`, `shipping_address`, `state`, `street1`, `title`, `updated_at`, `uptime`, `user_id`) VALUES (NULL, NULL, NULL, '2014-08-28 02:55:19', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL, NULL, '2014-08-28 02:55:19', NULL, 1)
class Billing < ActiveRecord::Base
# attr_accessible :user_id
attr_accessible :title, :birth, :ictype, :idno, :race, :gender, :national, :street1, :postcode, :city, :state, :marital, :shipping_address
belongs_to :user
end
Class ShoppingCartsController < ApplicationController
def create
@billing = Billing.new(params[:billing])
@billing = current_user.build_billing
@billing.save
end
end
为什么会这样?
【问题讨论】:
标签: ruby-on-rails-3 activerecord ruby-on-rails-3.2 activemodel