0
我新的軌道所以任何幫助,將不勝感激。我目前正在嘗試僅顯示已被招聘人員邀請申請職位的用戶。您的意見將非常感謝 - 感謝你檢索從列表中通過迭代的ID - 軌道4
我有4種型號:用戶/招聘/邀請/表格/廣告
網友[求職]:用戶使用的形式(申請表)申請一個廣告(工作後)
招聘:招聘人員創造廣告(工種),並可以發送邀請給用戶[求職]申請一個廣告[工作職位]
型號:
user has_many invites
user has_many forms
recruiter has_many invites
recruiter has_many adverts
invite belongs_to a user
invite belongs_to a recruiter
invite belongs_to an advert
form belongs_to a user
form belongs_to an advert
advert belongs_to a recruiter
advert has_many forms
控制器
class RecruitersController < ApplicationController
def dashboard
@invites = @recruiter.invites
end
end
意見
recruiters/dashboard.html.erb
<table>
<thead>
<tr>
<th>date</th>
<th>invite info</th>
<th>jobseeker has accepted invite & has applied - view application</th>
</tr>
</thead>
<tbody>
<% @invites.each do |invite| %>
<tr>
<td><%= invite.created_at.strftime("%B %d, %Y") %></td>
<td>
<div>you invited
<b><%= link_to "#{invite.user.firstname} #{invite.user.lastname}", user_path(invite.user) %></b>
to apply for
<b><%= link_to "#{invite.advert.title}", recruiter_advert_path(invite.recruiter, invite.advert) %></b></div>
</td>
<td>
<ul>
<% invite.advert.forms.each do |form| %>
<li><%= link_to form.user.firstname, form %> form |
applied <%= form.created_at.strftime("%B %d, %Y") %></li>
<% end %>
</ul>
</td>
</tr>
<% end %>
</tbody>
</table>
我試圖只顯示已邀請招聘用戶申請這份工作,而是我得到的所有已應用作業的用戶。我嘗試使用「.where()」方法,但沒有運氣。您的意見將非常感謝 - 感謝你
你試過'@ invites.where(USER_ID:id_of_user)'時,你會檢索到的'id_of_user' FR om單獨的查詢,或者您可以加入表格來執行單個查詢。 – bjhaid