无法删除 rails_admin 中的对象

Cannot delete object in rails_admin

当我尝试删除名为 place 的模型实例时,出现以下错误。该模型具有以下类型的属性:stringdatetimeint4rangebooleannumrangeintegertext, decimal, float.

我正在使用 rails 4.2.4,ruby 2.2.1,pg 9.4.5

我遇到过一次这个问题,就我而言,我发现它发生是因为 Rails 管理员试图显示这种关系。这一路走来出错。

我通过覆盖 rails_admin show delete 视图解决了这个问题 只是创造 views/rais_admin/main/_delete_notice.html.haml 然后放

- object = delete_notice

%li{style: 'display:block; margin-top:10px'}
  %span.label.label-default= @abstract_model.pretty_name
  - wording = object.send(@model_config.object_label_method)
  - if show_action = action(:show, @abstract_model, object)
    = link_to(wording, url_for(action: show_action.action_name, model_name: @abstract_model.to_param, id: object.id), class: 'pjax')
  - else
    = wording
  %ul
    - @abstract_model.each_associated_children(object) do |association, child|
      -#- unless child.kind_of?(String) || child.kind_of?(ActsAsTaggableOn::Tagging)
      - if child.kind_of?(ActiveRecord::Base)
        %li
          - child_config = RailsAdmin.config(child)
          = @abstract_model.model.human_attribute_name association.name
          - wording = child.send(child_config.object_label_method)
          - if child.id && (show_action = action(:show, child_config.abstract_model, child))
            = link_to(wording, url_for(action: show_action.action_name, model_name: child_config.abstract_model.to_param, id: child.id), class: 'pjax')
          - else
            = wording

- if child.kind_of?(ActiveRecord::Base) 阻止进一步检查模型属性,这导致 undefined method model for nil:NilClass 在您的错误日志中