I have an association between jobs and companies where company has_many: jobs
and job belongs_to: company
. Now I am trying to access a page where there are only companies that have a job, so for this i have this code in my controller
def recruiting
@companies = Company.all
end
and this is my recruiting page
<% @companies.each do |company| %>
<% unless company.job.nil? %>
<%= link_to company.name, company_path(company), title: "#{company.name}" %>
<% end %>
<% end %>
This doesn't work and gives me an error undefined method job'