我有一个具有以下关联的用户模型和消息模型
用户模型user.rb
has_many :sent_messages, dependent: :destroy,
:class_name => 'Message',
:primary_key=>'unique_id',
:foreign_key => 'sender_id',
:order => "messages.created_at DESC",
:conditions => ["messages.sender_deleted = ?", false]
has_many :received_messages, dependent: :destroy,
:class_name => 'Message',
:primary_key=>'unique_id',
:foreign_key => 'recepient_id',
:order => "messages.created_at DESC",
:conditions => ["messages.recepient_deleted = ?", false]
消息模型message.rb
belongs_to :sender,
:class_name => 'User',
:primary_key => 'unique_id',
:foreign_key => 'sender_id'
belongs_to :recepient,
:class_name => 'User',
:primary_key => 'unique_id',
:foreign_key => 'recepient_id'
在带有 rails_admin 的管理面板中,当我尝试编辑用户详细信息时,出现以下错误undefined method unique_id for #<Message:0x00000005b5efa0>
Extracted source (around line #10):
7 selected = [config.abstract_model.get(related_id)]
8 else
9 selected = form.object.send(field.name)
10 end
11 selected_ids = selected.map{|s| s.send(field.associated_primary_key)}
12
13 current_action = params[:action].in?(['create', 'new']) ? 'create' : 'update'
任何有帮助的人,我将不胜感激。
我正在使用 gem devise 来管理用户,并使用 rails_admin 来管理管理员