Commit fe7cebed by Xuan Trung Le

fix bugs: jobs can apply when out of date

parent 4f6a51d3
class AppliesController < ApplicationController
before_action :admin_can_not_do_this
before_action :authenticate_user!
before_action :check_deadline
def apply
session[:job_id] = params[:job_id] if params[:job_id]
if session[:candidate].present?
......@@ -45,4 +46,12 @@ class AppliesController < ApplicationController
def application_params
params.require(:apply_job).permit(:name, :email, :cv)
end
def check_deadline
job = Job.find(params[:job_id])
if Date.today > job.expiry_date
flash[:notice] = "Job was expiried date"
redirect_back(fallback_location: root_path)
end
end
end
......@@ -24,16 +24,17 @@
</div>
<% end %>
<div class="col-md-9">
<h1>2.<%= @job.name %></h1>
<p>3.<%= link_to @job.company.name, company_jobs_path(@job.company) %></p>
<p>4. Location:
<h1><%= @job.name %></h1>
<p><%= link_to @job.company.name, company_jobs_path(@job.company) %></p>
<p>Location:
<%- @job.cities.each_with_index do |city, index| -%>
<%= "#{index > 0 ? ',' : ''}" %>
<%= link_to city.name, city_jobs_path(city) %>
<%- end -%>
</p>
<p>5. Salary: <%= @job.salary %></p>
<p>6 Long Description:
<p>Salary: <%= @job.salary %></p>
<p>Deadline to apply: <%= l @job.expiry_date, format: :default %></p>
<p>Long Description:
<%= @job.description.html_safe %>
</p>
</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