质量分配错误

时间:2016-06-16 12:52:06

标签: ruby-on-rails slim-lang

Rails 3.2

在我的表格中,我有以下(使用苗条):

= form_for CustomerInfo.new :url => {:action => "create"}, :method => "post" do |f|
....
....
.actions = f.submit 'Save'

这会产生以下错误:

Can't mass-assign protected attributes: url, method

在我的routes.rb中,我有:

post '/customer_infos' => 'customer_infos#create', as: 'customer_info'

Rails 3.2下是不允许这种语法?

解决方案:

我解决了这个问题:

= form_fo(CustomerInfo.new :url customer_info_path) do |f|

1 个答案:

答案 0 :(得分:0)

尝试

customer_infos控制器:

def new
 @customer_info = CustomerInfo.new()
end

形式:

form_for(@customer_info) do |f|
  ....
  ....
f.submit