0

我想按他们的所有者对培训进行排序,他们的名字包含在我的个人资料模型中。培训属于个人资料。

我的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)
4

1 回答 1

1

您可以尝试以下方法:

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

让我知道这是否适合你!

于 2013-08-12T17:16:01.443 回答