Reputation: 547
I would like to sort the trainings by their owner, whose name is included in my profile model. A Training belongs to a Profile.
I have this in my trainings.rb:
column "Owner", :sortable => :profile_name do |training|
if training.profile.nil?
"No associated profile"
else
training.profile.name
end
end
I get this error in production:
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)
Upvotes: 0
Views: 141
Reputation: 2710
You could try the following:
column "Owner", :sortable => 'profile.name' do |training|
Let me know if that works for you!
Upvotes: 1