RailsCasts Pro episodes are now free!

Learn more or hide this

Eric Echeverri's Profile

GitHub User: ericeche

Site: www.umich.edu

Comments by Eric Echeverri

Avatar

Any progress in how to sort column data from associated tables using server side processing?

ruby
class Workshop < ActiveRecord::Base
  belongs_to :location, :class_name => 'Location'
end

class Location < ActiveRecord::Base
  has_many :workshops
  attr_accessible :name,
end

Records are associated by id ( workshop.id = location_id)

On the Workshop datatable class, the information displayed is the location_name

ruby
class WorkshopsDatatable

 def data
    workshops.map do |workshop|
      {
        id:           workshop.id,
        location:     workshop.location_name,
      }
    end
end

I would like to be able to sort the location column by location_name and not by location_id.