3

Rails 4.1.1、ruby 2.1、mongodb、mongoid をラッパーとして使用し、rails_admin を管理インターフェースの作成に使用しています。

「attr_accessible」がRails4では機能しなくなったことは知っています。だから私は 'protected_attributes' gemをインストールしました。しかし、まだ成功していません。コンソールにまだ警告が表示されます

[RailsAdmin] Could not load model Company, assuming model is non existing. (undefined method `attr_accessible' for Company:Class)

したがって、モデルでattr_accessibleを定義しているため、Rails管理者はCompanyクラスをロードしません。これが私の会社のモデルです。

  class Company
  include Mongoid::Document

  @@employees_strength = {0 => '0-10', 1 => '11-50', 2 => '51-100', 3 => '101-500', 4 => '501-1000', 5 => '1000+', 6 => '5000+'}

  field :name,          type: String
  field :website,       type: String
  field :domain_name,   type: String
  field :strength,      type: Integer

  has_many :employees
  has_one :admin, :class_name => 'Employee',  :dependent => :destroy, :inverse_of => :organization

  #attr_accessible :name, :website, :domain_name, :strength#, :admin_attributes, :allow_destroy => true
  attr_accessible :admin_attributes
  accepts_nested_attributes_for :admin, :allow_destroy => true
 end

助けてくれる体はありますか?ありがとう

4

1 に答える 1