Could you help me write a proper query in rails for accessing the following information?

Posted by aditi-syal on Stack Overflow See other posts from Stack Overflow or by aditi-syal
Published on 2010-03-12T13:04:40Z Indexed on 2010/03/12 13:07 UTC
Read the original article Hit count: 431

Filed under:
|
|
|

@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 

© Stack Overflow or respective owner

Related posts about rails

Related posts about associations