我正在使用复合主键gem和active_admin,我遇到了索引页面的问题。 我可以以某种方式自定义index.html.arb文件吗?或者更改belongs_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]**
应用程序/管理/ 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)
答案 0 :(得分:0)
我认为active_admin不接受复合键。 = /(Rails)
无论如何,请查看下面的链接,它可能对您有所帮助,并解释为什么active_admin在索引页面中查询所有belongs_to关联。
https://github.com/gregbell/active_admin/wiki/Preventing-Extra-Queries-on-Index-Pages