[英]Active_admin + Composite_primary_keys
我正在使用復合主鍵gem和active_admin,但索引頁出現問題。 我可以以某種方式自定義index.html.arb文件嗎? 或更改longate_to關聯?
我的模特:
class Vehicle < ActiveRecord::Base
self.table_name = "vehicle"
self.primary_key = "vehicle_id"
belongs_to :operator, :foreign_key => :operator_id
**belongs_to :orgunit, :foreign_key => [:operator_id, :run_code]**
app / admin / vehicles.rb
ActiveAdmin.register Vehicle do
index do
id_column
column :version
column :description
default_actions
結束
索引頁錯誤:
NoMethodError in Admin/vehicles#index
Showing /home/dev/.rvm/gems/ruby-1.9.3-p125@global/gems/activeadmin-
0.5.0/app/views/active_admin/resource/index.html.arb where line #1 raised:
undefined method `to_sym' for [:operator_id, :run_code]:Array
Extracted source (around line #1):
1: insert_tag renderer_for(:index)
我相信active_admin不接受組合鍵。 = /(任意滾動)
無論如何,請查看下面的此鏈接,它可能會對您有所幫助,並解釋為什么active_admin在“索引”頁面中查詢所有alls_to關聯。
https://github.com/gregbell/active_admin/wiki/Preventing-Extra-Queries-on-Index-Pages
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.