Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/57.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 尝试在rails 3.2中实现编辑时出错_Ruby On Rails_Ruby On Rails 3_Html_Ruby On Rails 3.2 - Fatal编程技术网

Ruby on rails 尝试在rails 3.2中实现编辑时出错

Ruby on rails 尝试在rails 3.2中实现编辑时出错,ruby-on-rails,ruby-on-rails-3,html,ruby-on-rails-3.2,Ruby On Rails,Ruby On Rails 3,Html,Ruby On Rails 3.2,我试图在我的项目中编辑一个名为categories的视图,但在尝试编辑时,我似乎遇到了一个非常奇怪的错误 显示的错误如下所示:- ActiveModel::MassAssignmentSecurity::Error in CategoriesController#update Can't mass-assign protected attributes: id, name, parent_cat_id Parameters: {"utf8"=>"✓", "_meth

我试图在我的项目中编辑一个名为categories的视图,但在尝试编辑时,我似乎遇到了一个非常奇怪的错误

显示的错误如下所示:-

    ActiveModel::MassAssignmentSecurity::Error in CategoriesController#update

    Can't mass-assign protected attributes: id, name, parent_cat_id

Parameters:

{"utf8"=>"✓",
 "_method"=>"put",
 "authenticity_token"=>"RaQQRvJRRmjg0HAy3utlrD2wKAvYXbtNC2hjR4JHpXs=",
 "category"=>{"id"=>"3",
 "name"=>"Non-Fictional",
 "parent_cat_id"=>"0"},
 "commit"=>"Update",
 "id"=>"3"}
id serial NOT NULL,
  name character varying(255),
  parent_cat_id integer DEFAULT 0,
  deleted integer NOT NULL DEFAULT 0,
  CONSTRAINT categories_pkey PRIMARY KEY (id)
class Category < ActiveRecord::Base

    attr_accessible :name, :parent_cat_id

    # ------- ASSOCIATIONS -----------

    has_many :books

    belongs_to :category, :foreign_key => 'parent_cat_id'
end
我的分类表如下:-

    ActiveModel::MassAssignmentSecurity::Error in CategoriesController#update

    Can't mass-assign protected attributes: id, name, parent_cat_id

Parameters:

{"utf8"=>"✓",
 "_method"=>"put",
 "authenticity_token"=>"RaQQRvJRRmjg0HAy3utlrD2wKAvYXbtNC2hjR4JHpXs=",
 "category"=>{"id"=>"3",
 "name"=>"Non-Fictional",
 "parent_cat_id"=>"0"},
 "commit"=>"Update",
 "id"=>"3"}
id serial NOT NULL,
  name character varying(255),
  parent_cat_id integer DEFAULT 0,
  deleted integer NOT NULL DEFAULT 0,
  CONSTRAINT categories_pkey PRIMARY KEY (id)
class Category < ActiveRecord::Base

    attr_accessible :name, :parent_cat_id

    # ------- ASSOCIATIONS -----------

    has_many :books

    belongs_to :category, :foreign_key => 'parent_cat_id'
end
我的类别模型文件如下所示:-

    ActiveModel::MassAssignmentSecurity::Error in CategoriesController#update

    Can't mass-assign protected attributes: id, name, parent_cat_id

Parameters:

{"utf8"=>"✓",
 "_method"=>"put",
 "authenticity_token"=>"RaQQRvJRRmjg0HAy3utlrD2wKAvYXbtNC2hjR4JHpXs=",
 "category"=>{"id"=>"3",
 "name"=>"Non-Fictional",
 "parent_cat_id"=>"0"},
 "commit"=>"Update",
 "id"=>"3"}
id serial NOT NULL,
  name character varying(255),
  parent_cat_id integer DEFAULT 0,
  deleted integer NOT NULL DEFAULT 0,
  CONSTRAINT categories_pkey PRIMARY KEY (id)
class Category < ActiveRecord::Base

    attr_accessible :name, :parent_cat_id

    # ------- ASSOCIATIONS -----------

    has_many :books

    belongs_to :category, :foreign_key => 'parent_cat_id'
end
类别'parent\u cat\u id'
结束
有人能帮我把这些字段(id、姓名、父类id)添加到分类模型中吗-

class Category < ActiveRecord::Base
  attr_accessible :name, :parent_cat_id, :id
    # ------- ASSOCIATIONS -----------
  has_many :books
  belongs_to :category, :foreign_key => 'parent_cat_id'
end
类别'parent\u cat\u id'
结束

显示您的
分类控制器#更新
方法实现的可能重复?