Reputation: 2497
I believe this is a fairly simple question but it is something I am struggling with a little. I currently have the following:
<% @jobs.each do |f| %>
<div class="job">
<div class="job-desc"><%= f.company %> are looking for a <%= f.job_title %>
<div class="job-sal"><%= f.job_salary %></div>
</div>
</div>
<% end %>
I would like to create it so that each job
instance is a link to that job's show page. What I can't work out is how to integrate rails' <%= link_to "something", job_path %>
I have tried placing the entire block of code into the "something" part in the example above but that doesn't seem to work.
Any ideas would be much appreciated :)
Upvotes: 1
Views: 505
Reputation: 2682
If I understand correctly,you want the entire divs to be links? If that is the case, please try the following:
<% @jobs.each do |job| %>
<%= link_to job_path(job) do %>
<div class="job">
<div class="job-desc"><%= job.company %> are looking for a <%= job.job_title %>
<div class="job-sal"><%= job.job_salary %></div>
</div>
</div>
<% end %>
<% end %>
I'd suggest having a look at it in rails API doc. http://api.rubyonrails.org/
Upvotes: 4