我有一个循环,不能在轨道上的红宝石上工作

时间:2014-10-13 19:02:00

标签: ruby-on-rails

我有循环检查是否没有图像显示虚拟图像。我不知道这个循环有什么问题。它不显示虚拟图像。任何帮助将不胜感激。谢谢

 .col-md-12
  - @applied_users.each do |user|
    .applied 
    %a
      %a.litle-modules.pull-left{href: show_user_public_path(user.id, ((Apply.where user_id: user.id, job_id: @job.id).first).id)}
        .col-xs-6.col-md-5
          .thumbnail
            - if user.image != nil
              = image_tag "profile_pic.jpeg"
            - elsif user.image.nil?
              = image_tag "profile_pic.jpeg"
        .col-md-7.pull-right
          %h2= user.fname
          %p= user.location
          %p= user.description

def show_private
        #this method is responsible for showing the companies their job application page after matches have been made and after people have applied. 
        neo_results_array = []
        percentage_match = []
        @job = Job.find(params[:id])
        @neo_results = Neo4jProcess.match_users(@job.id, 20000)

        filtered_results = JSON.parse(@neo_results)
        users = filtered_results["users"]
        users.each do |user|
            if user["score"] >= 0.005
                neo_results_array << user["user_id"]
                percentage_match << user["score"]
            else
            end
        end
        @final_array = neo_results_array.zip(percentage_match)
        print @final_array

        if @job.applies == [] && neo_results_array == []
            redirect_to share_page_path(@job.id)
        else @job.applies != [] || neo_results_array != []
            applied = @job.applies.pluck(:user_id)
            @applied_users = User.find(applied) 
            percentage_user_array = []

            @final_array.each do |item|
                percentage_user_array << item[0] 
            end
            @matched_users = User.find(percentage_user_array)
      end   
    end

刚刚编辑过。在这里你可以看到我的控制器负责img和其他东西

1 个答案:

答案 0 :(得分:0)

从else删除条件

如果你想为else设置一些条件,请使用

 elsif user.image.nil?