无法删除rails_admin

时间:2015-11-10 08:48:51

标签: ruby-on-rails rails-admin

当我尝试删除名为place的模型实例时,我收到以下错误。该模型具有以下类型的属性:stringdatetimeint4rangebooleannumrangeinteger,{{1} },textdecimal

我使用的是rails 4.2.4,ruby 2.2.1,第9.4.5页

enter image description here

1 个答案:

答案 0 :(得分:1)

我曾经遇到过这个问题,在我的情况下,我发现它发生了,因为Rails Admin试图显示这种关系。这一切都是错误的。

我通过覆盖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