0

我正在尝试使用activeadmin-mongoid将活动管理员与 mongoid 一起使用

class Student < User
  include Mongoid::Document
  field :dob, type: Date
  field :gender, type: String
  field :nick_name, type: String
  has_many :tasks

class Task
  include Mongoid::Document
  belongs_to :student

我正在注册

ActiveAdmin.register Student do   
  index do
    column :dob
    column :gender
    column :nick_name
    default_actions
  end
end

ActiveAdmin.register Task do
      belongs_to :student
end

但是,当我尝试在活动管理员中访问学生页面时。我得到错误

undefined method `tasks_id_eq' for #<MetaSearch::Searches::MongoidSearchBuilder:0x00000005b46bd0>

1: insert_tag renderer_for(:index)


activeadmin-mongoid (0.3.0) lib/meta_search/searches/mongoid.rb:90:in `method_missing'
actionpack (3.2.13) lib/action_view/helpers/form_helper.rb:1152:in `value'
actionpack (3.2.13) lib/action_view/helpers/form_helper.rb:1143:in `value'
actionpack (3.2.13) lib/action_view/helpers/form_options_helper.rb:580:in `to_select_tag'
actionpack (3.2.13) lib/action_view/helpers/form_options_helper.rb:157:in `select'
actionpack (3.2.13) lib/action_view/helpers/form_options_helper.rb:642:in `select'
formtastic (2.2.1) lib/formtastic/inputs/select_input.rb:154:in `select_html'
formtastic (2.2.1) lib/formtastic/inputs/select_input.rb:149:in `block in to_html'
actionpack (3.2.13) lib/action_view/helpers/capture_helper.rb:40:in `block in capture'
actionpack (3.2.13) lib/action_view/helpers/capture_helper.rb:187:in `with_output_buffer'
actionpack (3.2.13) lib/action_view/helpers/capture_helper.rb:40:in `capture'
4

1 回答 1

0

问题在于自动生成 has_many 和过滤器

解决方法定义过滤器并跳过关系。

于 2013-10-10T06:41:28.693 回答