1

我在尝试创建新限制或编辑限制时遇到此错误(以下模型)

Rails_admin/main#new 中的参数错误

显示 /Users/deini/.rvm/gems/ruby-2.0.0-p195/gems/rails_admin-0.4.9/app/views/rails_admin/main/_form_filtering_select.html.haml 其中第 11 行提出:

参数数量错误(0 表示 1+)

提取的源代码(第 11 行附近):(selected_id = field.selected_id)

    selected_id = selected.send(field.associated_primary_key)
     selected_name = selected.send(field.associated_object_label_method)
   else
     selected_id = field.selected_id
     selected_name = field.formatted_value
   end

系统.rb

class System < ActiveRecord::Base
  has_many :attachments

  has_many :limitations
  has_many :companies, :through => :limitations

  accepts_nested_attributes_for :attachments
  accepts_nested_attributes_for :companies

  attr_accessible :conf_type, :version, :hardware_type, :name, :attachments_attributes, :company_ids, :companies_attributes

  rails_admin do
    list do
      exclude_fields :created_at, :updated_at
    end
  end

end

公司.rb

  class Company < ActiveRecord::Base
  belongs_to :distributor
  has_many :users, dependent: :destroy

  has_many :limitations
  has_many :systems, :through => :limitations

  accepts_nested_attributes_for :limitations

  attr_accessible :distributor_id, :name, :system_ids, :email, :limitations_attributes

  rails_admin do
    list do
      exclude_fields :custom_url, :created_at, :updated_at
    end

    edit do
      exclude_fields :custom_url, :users
    end
  end

end

限制.rb

class Limitation < ActiveRecord::Base
  belongs_to :company
  belongs_to :system
  attr_accessible :company_id, :system_id, :version_limit
end

我没有在我的 rails_admin 中修改任何内容,对我做错了什么有任何想法吗?

4

1 回答 1

1

其实我也有同样的错误。但是,当我在整个代码中将名称System更改为其他名称时,包括模型、表名和所有名称,我的代码开始正常工作。尝试用其他单词更改名称System 。

于 2017-05-05T04:53:32.790 回答