Hi I try to sort column on rails, activeadmin. The code is just like this.
# app/admin/users.rb
show do
tab do
table_for do
# here comes my columns
I can find a good sorting solution from Sort a table_for in rails activeadmin. So I try this code and it works.
# app/admin/users.rb
show do
tab do
table_for user.supports.order(params[:order].gsub('_', ' ')), sortable: true do
column 'step', sortable: :step do |support|
support.step
end
But how can I sort this column in the same table_for?
# app/admin/users.rb
column 'date', sortable: 'payment.date' do |support|
support.payment.date
end
I tried a lot of things but cannot make it. My model code below.
# app/models/payment.rb
class Payment < ApplicationRecord
belongs_to :support
# app/models/support.rb
class CampaignSupport < ApplicationRecord
belongs_to :user
has_many :payment
# app/models/user.rb
class User < ApplicationRecord
has_many :support
Thanks