Commit 04a4e0b4 by nnnghia98

fix draper

parent a3d65929
......@@ -3,6 +3,7 @@ class JobDecorator < ApplicationDecorator
delegate_all
decorates_association :city
decorates_association :user
def city_name
object.cities&.first&.name
......@@ -19,4 +20,8 @@ class JobDecorator < ApplicationDecorator
def display_description
simple_format object.description
end
def apply_available(user)
object.users.find_by(id: user.id)
end
end
class UserDecorator < ApplicationDecorator
include ActionView::Helpers::TextHelper
delegate_all
decorates_association :jobs
def apply_available
object.jobs.find_by(job_id: jobs.id)
end
end
......@@ -32,7 +32,7 @@
<div class="job_detail_button">
<%= link_to "Favorite", "#", class: "btn btn-primary float-right" %>
<% if user_signed_in? && UserJob.find_by(user_id: current_user.id, job_id: @job.id) %>
<% if user_signed_in? && @job.apply_available(current_user) %>
<button type="button" class="btn btn-primary float-right mx-3" disabled>Apply</button>
<% else %>
<%= link_to "Apply", apply_path(job_id: @job.id), class: "btn btn-primary float-right mx-3" %>
......
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