我有这些联想
class Job
has_many :job_applications
end
def JobApplication
belongs_to :job
has_one :vote_count
end
def VoteCount
#attribute counts And counts can be 4,5,1,2,6...
belongs_to :job_application
end
现在我想排序
@job = 1 #id = 1
job_applications = @job.job_applications.sort_by!{|a| a.vote.counts}
我需要包括所有工作申请,如果工作申请没有投票关联,它应该是 0。但我没有例外。
任何帮助...