2013-08-12 23 views
0

我想按其所有者對其培訓進行排序,其所有者名稱包含在我的配置文件模型中。 培訓屬於配置文件。ActiveAdmin在生產中可排序的錯誤

我有這個在我的trainings.rb:

column "Owner", :sortable => :profile_name do |training| 
    if training.profile.nil? 
     "No associated profile" 
    else 
     training.profile.name 
    end 
end 

我在生產中得到這個錯誤:

Completed 500 Internal Server Error in 19ms 

ActionView::Template::Error (PG::UndefinedColumn: ERROR: column "profile_name" does not exist 
LINE 1: SELECT "trainings".* FROM "trainings" ORDER BY "profile_na... 
                 ^
: SELECT "trainings".* FROM "trainings" ORDER BY "profile_name" desc LIMIT 30 OFFSET 0): 
    1: insert_tag renderer_for(:index) 

回答

1

你可以嘗試以下方法:

column "Owner", :sortable => 'profile.name' do |training| 

讓我知道如果這對你有用!