当我尝试删除名为place
的模型实例时,我收到以下错误。该模型具有以下类型的属性:string
,datetime
,int4range
,boolean
,numrange
,integer
,{{1} },text
,decimal
。
我使用的是rails 4.2.4,ruby 2.2.1,第9.4.5页
答案 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