Could you help me write a proper query in rails for accessing the following information?
- by aditi-syal
@workname = []
@recos = []
@bas = []
if current_user.recommendations.size != 0
current_user.recommendations.each do |r|
if r.work_type == 'J'
@job = Job.find_by_id(r.work_id)
@workname.push "#{@job.title} at #{@job.company.name}"
else
@qualification = Qualification.find_by_id(r.work_id)
@workname.push "Student at #{@qualification.school_name}"
end
@recommender = User.find_by_id(r.recommender_id)
if r.recommender_work_type == 'J'
@job = Job.find_by_id(r.recommender_work_id)
@recos.push "#{@recommender.first_name} #{@recommender.last_name}"
@bas.push "#{r.basis.gsub("You","#{@job.title} at #{@job.company.name}")}"
else
@qualification = Qualification.find_by_id(r.recommender_work_id)
@recos.push "#{@recommender.first_name} #{@recommender.last_name} as "
@bas.push "#{r.basis.gsub("You","Student at #{@qualification.school_name}")}"
end
end
end