Commit 0173688a by Thanh Hung Pham

Fix comment - Don't query DB in view

parent 58da1976
...@@ -49,6 +49,7 @@ class JobsController < ApplicationController ...@@ -49,6 +49,7 @@ class JobsController < ApplicationController
end end
def index def index
@favorite = Favorite.where(user: current_user, job: job)
end end
def favorite def favorite
......
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
<td> <%= job.city.try(:name) %> </td> <td> <%= job.city.try(:name) %> </td>
<td> <%= job.salary %> </td> <td> <%= job.salary %> </td>
<td> <td>
<% if Favorite.where(user: current_user, job: job).blank? %> <% if @favorite.blank? %>
<div class="col-md-3" id="favorite_<%= job.id %>"> <div class="col-md-3" id="favorite_<%= job.id %>">
<%= link_to 'Favorite', jobs_favorite_path(job_id: job.id, format: 'js'), remote: true, class: 'favorite_add' %> <%= link_to 'Favorite', jobs_favorite_path(job_id: job.id, format: 'js'), remote: true, class: 'favorite_add' %>
</div> </div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment