handling order with has_many through relationship

I think something like that can help you:

has_many :project_tasks
has_many :tasks, :through => :project_tasks, :order => 'project_tasks.position'

class Task < AR::Base
   belongs_to :project
   has_one :project_tasks,:through=>:project_tasks
end

class Project < AR::Base 
  has_many :project_tasks
  has_many :tasks ,:through=>:project_tasks,:order => 'project_tasks.position'
end

class ProjectTask < AR::Base
  belongs_to :task
  belongs_to :project
end

This is what works for me in Rails 5.x :

has_many :project_tasks
has_many :tasks, -> { order('project_tasks.position') }, through: :project_tasks